[英]Emacs' align fails in plsql-mode
I've been using a PL/SQL mode available on EmacsWiki and I have been a rather happy with it. 我一直在使用EmacsWiki上的PL / SQL模式 , 对此我感到非常满意。
But when I try to align
or align-current
I just get an error: 但是当我尝试
align
或align-current
我只会得到一个错误:
align: Wrong type argument: sequencep, plsql-align-rules-list
Example code that I'm trying to align: 我要对齐的示例代码:
declare
foo number;
x number;
y number;
begin
foo := 5;
x := 123;
y:=123;
end;
The expected outcome is: 预期结果是:
declare
foo number;
x number;
y number;
begin
foo := 5;
x := 123;
y := 123;
end;
Here is the relevant (I hope) part of the plsql-mode's code: 这是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.
))
And later in defun plsql-mode ()
: 然后在
defun plsql-mode ()
:
(set (make-local-variable 'align-mode-rules-list) 'plsql-align-rules-list)
How the plsql-mode should be modified to get align
working ? 应该如何修改plsql-mode才能
align
工作? My best work-around so far is to use align-regexp
(inspired by this answer ): 到目前为止,我最好的解决方法是使用
align-regexp
(受此答案启发):
(defun my-align ()
""
(interactive)
(align-regexp
(region-beginning) (region-end)
"\\(\\s-*\\):=" 1 1 nil))
This is fine except it doesn't modify the right-hand side. 很好,只不过它不会修改右侧。
The author doesn't use the mode anymore. 作者不再使用该模式。 I'm using emacs 23.2.1.
我正在使用emacs 23.2.1。
As far as I can understand it, the function plsql-mode should contain: 据我了解,函数plsql-mode应该包含:
(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)
Since the first two buffer local variables are indeed references to functions, their argument should be a quoted symbol. 由于前两个缓冲区局部变量确实是对函数的引用,因此其参数应为带引号的符号。 Since the third one should use the value contained in the variable plsql-align-rules-list, this variable should NOT be quoted.
由于第三个变量应使用变量plsql-align-rules-list中包含的值,因此不应引用该变量。
HTH )jack( HTH)千斤顶
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.