2011-11-22 86 views
1

我一直在使用上的PL/SQL mode,我一直對此感到滿意。Emacs'對齊在plsql模式下失敗

但是,當我嘗試alignalign-current我剛剛得到一個錯誤:

declare 
    foo number; 
    x number; 
    y number; 
begin 
    foo :=  5; 
    x := 123; 
    y:=123; 
end; 

預期的結果是:

,我試圖對準

align: Wrong type argument: sequencep, plsql-align-rules-list 

示例代碼

declare 
    foo number; 
    x number; 
    y number; 
begin 
    foo := 5; 
    x := 123; 
    y := 123; 
end; 

以下是plsql-mode代碼的相關部分(我希望):

;;;_ + Align 

;; Should I make so that anything that is highlighted will line up? 
;; Should we make a block anything inside()? 

(eval-and-compile 

    (defcustom plsql-align-rules-list '() "" 
    :group 'plsql 
    :type 'align-rules-list-type) 

    ;; Should I make so that anything that is highlighted will line up? 
    ;; Should we make a block anything inside()? 

    (when (condition-case nil 
      (require 'align) 
      (error nil)) 

    ;; these are way too slow to use with indent before aligning 
    (unless (and plsql-align-rules-list plsql-debug) 
     (setq plsql-align-rules-list 
      '(
       (plsql-assignment 
       (regexp . "\\(\\s-*\\):=\\(\\s-*\\)") 
       (group . (1 2)) 
       (modes . '(plsql-mode)) 
       (repeat t) 
       (tab-stop . nil)) 

       (plsql-arrorw 
       (regexp . "\\(\\s-*\\)=>\\(\\s-*\\)") 
       (group . (1 2)) 
       (modes . '(plsql-mode)) 
       (repeat t) 
       (tab-stop . nil)) 

       (plsql-equals ;; exclude the previous two cases 
       (regexp . "\\(\\s-*[^:]\\)=\\([^>]\\s-*\\)") 
       (group . (1 2)) 
       (repeat t) 
       (tab-stop . nil) 
       (modes . '(plsql-mode))) 

       (plsql-operator ;; watch out for comments 
       (regexp . "\\(\\s-*\\)[-+/]{1}\\(\\s-*\\)") 
       (group . (1 2)) 
       (repeat t) 
       (tab-stop . nil) 
       (modes . '(plsql-mode))) 

       (plsql-keywords 
       (regexp . "\\(\\s-+\\)\\(in\\|default\\|number\\|varchar2\\|blob\\|raw\\)\\b") 
       (group 1) 
       (repeat t) 
       (case-fold t) 
       (tab-stop . nil) 
       (modes . '(plsql-mode))) 
      ) 
      )) 

    (put 'plsql-align-rules-list 'risky-local-variable t) 
    (add-to-list 'align-c++-modes 'plsql-mode) ;; eg expression functions ... 
    (add-to-list 'align-sq-string-modes 'plsql-mode) 
    (add-to-list 'align-open-comment-modes 'plsql-mode) 

    ;; Should we re-bind new-line-and-indent to align the current 
    ;; region? That sounds expensive. 
    )) 

後來在defun plsql-mode()

(set (make-local-variable 'align-mode-rules-list) 'plsql-align-rules-list) 

如何PLSQL模式應該進行修改,以獲得align工作?我最好的變通到目前爲止是使用align-regexp(由this answer啓發):

(defun my-align() 
    "" 
    (interactive) 
    (align-regexp 
    (region-beginning) (region-end) 
    "\\(\\s-*\\):=" 1 1 nil)) 

這是好的但它不會修改右側。

作者不再使用該模式。我使用的是emacs 23.2.1。

回答

0

至於我能理解它,功能PLSQL模式應該包含:

(set (make-local-variable 'indent-line-function) 'plsql-indent) 
(set (make-local-variable 'indent-region-function) 'plsql-indent-region) 
(set (make-local-variable 'align-mode-rules-list) plsql-align-rules-list) 

由於前兩個緩衝局部變量確實對函數的引用,他們的說法應該是引用符號。 由於第三個應該使用變量plsql-align-rules-list中包含的值,因此不應該引用此變量。

HTH )千斤頂(