启动选择以替换Emacs的转发字
我想替换Emacs的默认正向字和反向字,使其操作更像VisualStudio——我发现这更适合Perl编程。我首先尝试破解语法表,但没有达到我想要的效果。然后我想到了以下几点:启动选择以替换Emacs的转发字,emacs,elisp,Emacs,Elisp,我想替换Emacs的默认正向字和反向字,使其操作更像VisualStudio——我发现这更适合Perl编程。我首先尝试破解语法表,但没有达到我想要的效果。然后我想到了以下几点: (defconst perl-movement-stop-chars "a-zA-Z$@%_0-9'") (defconst perl-movement-stop-pattern (concat "[" perl-movement-stop-chars "]")) (defconst non-perl-movement-
(defconst perl-movement-stop-chars "a-zA-Z$@%_0-9'")
(defconst perl-movement-stop-pattern (concat "[" perl-movement-stop-chars "]"))
(defconst non-perl-movement-stop-pattern (concat "[^" perl-movement-stop-chars "]"))
(defun perl-forward-word ()
(interactive)
(if (looking-at perl-movement-stop-pattern)
(progn
(if (re-search-forward non-perl-movement-stop-pattern nil t)
(backward-char)))
(if (re-search-forward perl-movement-stop-pattern nil t)
(backward-char))))
(defun perl-backward-word ()
(interactive)
(backward-char)
(if (looking-at perl-movement-stop-pattern)
(progn
(if (re-search-backward non-perl-movement-stop-pattern nil t)
(forward-char)))
(if (re-search-backward perl-movement-stop-pattern nil t)
(forward-char))))
(add-hook 'cperl-mode-hook
(lambda()
(local-set-key [C-right] 'perl-forward-word)
(local-set-key [C-left] 'perl-backward-word)
linum-mode))
这就是我想要的——几乎是:当从缓冲区中的第一个字向后移动时,我仍然必须处理这个情况。但这不是我的问题
这样做的问题是,当我键入C-S-right时,选择没有启动,就像我的钩子没有安装或处于其他模式时一样。如果我启动选择,例如通过点击第一个S-右键,我的函数会扩展它
我对elisp编程知之甚少,我只是在猜测我的方法。如果能给我一点帮助,我将不胜感激。谢谢…要使换档选择模式工作,您需要使用interactive^。试试C-h f互动网
顺便说一句,你可以大大简化你的代码:要向前移动,只需向前重新搜索。\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\。无。要使shift select模式工作,您需要使用interactive^。试试C-h f互动网
顺便说一句,你可以大大简化你的代码:要向前移动,只需向前重新搜索。\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\。没有。我不确定你到底想要什么,但我想我会提供这个。我有一个我称之为Melpa的包。它使单词移动更加细粒度,以至于我几乎从不按字符移动,并使用其他解决方案(如isearch)移动更大的距离 从评论中:
;; This package provides `syntax-subword' minor mode, which extends
;; `subword-mode' to make word editing and motion more fine-grained.
;; Basically, it makes syntax changes, CamelCaseWords, and the normal
;; word boundaries the boundaries for word operations. Here's an
;; example of where the cursor stops using `forward-word' in
;; `emacs-lisp-mode':
;;
;; (defun FooBar (arg) "doc string"
;; | | | | | | standard
;; | | | | | | | subword-mode
;; || || | ||| |||| || || syntax-subword-mode
;; || | || | || | | vim
我不确定你到底想要什么,但我想我会提供这个。我有一个我称之为Melpa的包。它使单词移动更加细粒度,以至于我几乎从不按字符移动,并使用其他解决方案(如isearch)移动更大的距离 从评论中:
;; This package provides `syntax-subword' minor mode, which extends
;; `subword-mode' to make word editing and motion more fine-grained.
;; Basically, it makes syntax changes, CamelCaseWords, and the normal
;; word boundaries the boundaries for word operations. Here's an
;; example of where the cursor stops using `forward-word' in
;; `emacs-lisp-mode':
;;
;; (defun FooBar (arg) "doc string"
;; | | | | | | standard
;; | | | | | | | subword-mode
;; || || | ||| |||| || || syntax-subword-mode
;; || | || | || | | vim
你能描述一下你想要实现什么,而不是说更像Visual Studio的操作以及现在正在发生的事情吗?当点位于停止字符[a-zA-Z$@%\U 0-9']上时,我想向前或向后移动,直到它不再存在。当它不在停止字符上时,我想移动直到它停止。换句话说,我想很容易地从一个单词的内部移动到它的结尾,然后移动到下一个单词的开头,然后刚好经过下一个单词的结尾,等等-我对这个词的定义有点不标准。你能描述一下你想要实现什么,而不是说更像Visual Studio的操作和现在正在发生的事情吗。当点在停止字符[a-zA-Z$@%\U 0-9']上时,我想向前或向后移动,直到它不再存在。当它不在停止字符上时,我想移动直到它停止。换句话说,我想很容易地从一个单词的内部移动到它的结尾,然后移动到下一个单词的开头,然后刚好经过下一个单词的结尾,等等-我对这个单词的定义有点不标准。谢谢。顺便说一句,这个建议并没有给出我想要的结果,我想是因为它依赖于语法表中单词的正常定义,那么也许我应该修改语法表。然而,互动建议正是我所需要的。具体来说,它超越了第二个用法:严格使用;使用警告;我无法重现你的特殊问题,但我怀疑问题就在于此。在两个正则表达式中应替换为\\.\\\\n\\n。谢谢。顺便说一句,这个建议并没有给出我想要的结果,我想是因为它依赖于语法表中单词的正常定义,那么也许我应该修改语法表。然而,互动建议正是我所需要的。具体来说,它超越了第二个用法:严格使用;使用警告;我无法重现你的特殊问题,但我怀疑问题就在于此。在两个正则表达式中应替换为\\.\\\\n\\。