开发者

Emacs Lisp Align Keybinding Definition in init file

I have the following line in my Emacs init file.

(global-set-key (kbd "C-x a r") 'align-regexp)开发者_如何学Go

Is there any way to hard-code in a particular regex so that I don't have to specify it every time?


You could create your own command with the hard-coded regexp like so:

(defun align-specific-regexp (beg end)
  "Call 'align-regexp with the regexp ..."
  (interactive "r")
  (align-regexp beg end "^some.*regexp\\(here\\)?"))


You could just bind that key-sequence to a keyboard-macro:

(fset 'my-align-regexp
   [?\M-x ?a ?l ?i ?g ?n ?- ?r ?e ?g ?e ?x ?p return ?f ?o ?o return])

(global-set-key (kbd "C-x a r") 'my-align-regexp)

Create a keyboard macro with M-xalign-regexp then enter your regex.

Then insert the macro into your .emacs file with M-xinsert-kbd-macro return return

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜