Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent comment column #922

Open
veripoolbot opened this issue May 15, 2015 · 6 comments
Open

Consistent comment column #922

veripoolbot opened this issue May 15, 2015 · 6 comments
Labels

Comments

@veripoolbot
Copy link
Collaborator


Author Name: Monte Becker
Original Redmine Issue: 922 from https://www.veripool.org


Hi there:

I've had a devil of a time getting comments to start in the column I'd like for the systemVerilog/class work I do. This does not work:

( setq verilog-minimum-comment-distance 56 )

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Monte Becker
Original Date: 2015-05-15T13:21:55Z


From Greg waters, a suggestion related to the same topic:

Hi Alex,
I add the “var” keyword in front of user types in a declaration statement or ANSI port item, to give the parser more clues that a user typedef name precedes the port or variable name. I mention that in case you can build on it to improve indentation for types.

More generally, how about adding a special comment marker? If a line within a declaration or port “region” would be auto-indented, but it has an end-of-line comment with the special mark, can the autoindenter leave that line alone and just auto-indent the other lines (which don’t have a user typedef in them)?
This give the user a way to auto-indent declarations and ANSI ports that have built-in type names, while not affecting the ones that Verilog-mode can’t comprehend.

Suppose the “keep-indent” marker is “//.”. We could improve user-type indentation this way (I use dot-space here to suppress auto-replace in e-mail composer):

module foo
.(input logic. . . . . . . . . . .clk,
..input my_pkg::user_type. . . . .keep_type_way_left, //.  <==Keep-indent marker
..output logic . . . . . . . . . .done);

import my_pkg::*;
logic [7:0]. . . . . . . . .city_bus;
var user_type. . . . . . . .keep_type_also_way_left; //.  <==Keep-indent marker

endmodule

With the help of this marker, Verilog-mode can continue to re-indent the unmarked lines nicely. The marked lines would have manual indentation.

Thanks --Greg

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-05-15T13:55:58Z


Added pre's.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Kaushal Modi
Original Date: 2015-06-23T16:23:12Z


@monte

See if the below advice statements work for you (Works on GNU emacs 24.4+).

(defun my/verilog-selective-indent (&rest args)
  (interactive)
  (save-excursion
     (beginning-of-line)
     (let ((match (looking-at "^.*//\\."))) 
       match)))
;; Advise the indentation behavior of `indent-region' done using `C-M-\'
(advice-add 'verilog-indent-line-relative :before-until #'my/verilog-selective-indent)
;; Advise the indentation done by hitting `TAB'
(advice-add 'verilog-indent-line          :before-until #'my/verilog-selective-indent)

I "have something similar":https://github.com/kaushalmodi/.emacs.d/blob/b80883ca52fc4f6f474f94fd5c41cfc0fcd7ead8/setup-files/setup-verilog.el#L344-L363 to skip auto-indentation on certain lines.

Related "Issue #885":http://www.veripool.org/issues/885-Verilog-mode-Ignore-lines-starting-with-certain-characters-from-indenting-automatically-Feature-request-

@wilson:
Can we add a @defcustom@ regexp var (@nil@ by default)? If that var is non-nil, lines matching that regexp are not auto-indented.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Monte Becker
Original Date: 2015-06-23T19:33:21Z


Hi there. Thanks for the suggestion. Alas, it didn't work for me. Perhaps that is because I'm using an old version of emacs (v23.1.1). The message I get is:

Symbol's function definition is void: advice-add

I'm not adverse to getting an updated version of emacs, but would like to know if that's the problem before I start down that path (it would be non trivial where I work).

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Kaushal Modi
Original Date: 2015-06-24T16:07:40Z


@advice-add@ will work only in emacs 24.4 and newer versions (the newest released version as of now is 24.5).

I have not used the older advice system. Maybe someone well-versed in that can show you how to advise those functions using the old style.

On a side note, getting the latest emacs version would really help as it comes with many bug fixes and new features.
You can build emacs locally in your $HOME directory at work without needing any admin/su rights.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2017-11-19T13:26:05Z


Still present, perhaps someone would like to contribute a patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant