help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding multi-group regexps to align-rules-list


From: Scott Frazer
Subject: Re: Adding multi-group regexps to align-rules-list
Date: Thu, 21 May 2009 09:49:41 -0400
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

Peter Monsson wrote:

I'm trying to extend verilog mode with an alignment of input and
output ports such that

  (
   input test,
   output test,
   input [13:0] gfdgtrg,
   output [112:1] dsfsf,
   output control
   );

becomes

  (
   input          test,
   output         test,
   input  [13:0]  gfdgtrg,
   output [112:1] dsfsf,
   output         control
   );

But I keep getting wrong type argument: integer-or-marker-p on the
group list. I've tried quoting, backtick, cons cells, lists, etc. but
nothing works. The documentation says that lists are allowed in group
and from skimming the source code it seems to be implemented as well.
So what am I doing wrong?

(add-hook 'align-load-hook (lambda ()
       (add-to-list 'align-rules-list
                    '(verilog-port-args
                      (regexp  . "\\(?:in\\|out\\)put\\(?:\\(\\s-+\\)\\
(?:\\[.*\\]\\(\\s-+\\)\\)?\\)")
                      (group . (1 . (2 . ( 3 . 4))))
                      (modes   . '(verilog-mode))
                      (repeat  . t)))))


Here's what I have (although written long ago when my elisp was more naive):

(defcustom align-verilog-rules-list
  `(
    (verilog-declaration
     (regexp . 
"\\(logic\\|input\\|output\\|inout\\|wire\\|reg\\)\\(\\s-+[[][^]]+[]]\\|\\)\\(\\s-+\\)\\S-")
     (group . (3)))

    (verilog-asgn_param
     (regexp . "\\(assign\\|parameter\\)\\(\\s-+\\)\\S-")
     (group . (2)))

    (verilog-assign
     (regexp . "\\S-+\\(\\s-*\\)[!=><]+\\(\\s-*\\)\\S-")
     (group . (1 2)))

    (verilog-ports-no-comment
     (regexp . "[.][a-zA-Z0-9_]+\\(\\s-+\\)\\S-")
     (group . (1)))

    (verilog-ports-comment
     (regexp . "[.][a-zA-Z0-9_]+\\(\\s-+\\)\\S-.*\\(\\s-+\\)[/]+")
     (group . (1 2)))
    )
  "Verilog alignment rules."
  :type align-rules-list-type
  :group 'align)

(defcustom align-exclude-verilog-rules-list
  `(
    (exc-dq-string
     (regexp . "\"\\([^\"\n]+\\)\"")
     (repeat . t)
     (modes . align-dq-string-modes))

    (exc-open-comment
     (regexp . ,(function (lambda (end reverse)
        (funcall (if reverse 're-search-backward 're-search-forward)
                 (concat "[^ \t\n\\\\]" (regexp-quote comment-start)
                         "\\(.+\\)$") end t))))
     (modes . align-open-comment-modes))
    )
  "Verilog alignment exclusion rules."
  :type align-exclude-rules-list-type
  :group 'align)

(put 'align-verilog-rules-list 'risky-local-variable t)
(put 'align-exclude-verilog-rules-list 'risky-local-variable t)

(add-to-list 'align-dq-string-modes 'verilog-mode)
(add-to-list 'align-open-comment-modes 'verilog-mode)

(defun verilog-extras-hook ()
  (setq align-mode-rules-list align-verilog-rules-list)
  (setq align-exclude-rules-list align-exclude-verilog-rules-list))

(add-hook 'verilog-mode-hook 'verilog-extras-hook t)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]