Emacs lisp“shell-command-on-region”
发布时间:2020-12-15 19:09:27 所属栏目:安全 来源:网络整理
导读:在GNU Emacs中,我想在当前选定的文本上运行一个程序,figlet。然后我想评论所生产的地区。 我已经弄清楚如何使用标准的Emacs命令: 使用C- space设置标记在这个词的开始 移动光标到单词的末尾 C-u M-x区域命令RET图形RET M-x注释区域RET 但是,我没有想出如
在GNU Emacs中,我想在当前选定的文本上运行一个程序,figlet。然后我想评论所生产的地区。
我已经弄清楚如何使用标准的Emacs命令: >使用C-< space>设置标记在这个词的开始 但是,我没有想出如何编写一个Emacs lisp程序来做这些。这是我的尝试: (defun figlet-region () (interactive) (push-mark) (shell-command-on-region "figlet") (comment-region (mark) (point)) (pop-mark) ) (global-set-key "C-cC-f" 'figlet-region) 然后C-< space>; M-x figlet地区生产垃圾: figlet-region: Wrong number of arguments: #[(start end command &optional output-buffer replace error-buffer display-error-buffer) "??è "!é 'jê!j;j 0Wb ??`ì"í ?Q?DR?é!"& ff? )?Dq?!#ò#p=?é$]d|e^|íed ??D??é!"&a%qé$á&%ó *í é?#Dú#é!"&*#?!#??×!8WrD!qd`Z'o ?cùé"d'Zb)(úp!)?!*" [error-buffer small-temporary-file-directory temporary-file-directory exit-status error-file replace make-temp-file expand-file-name "scor" nil ...] 9 1945557 (let (string) (unless (mark) (error "The mark is not set now,so there is no region")) (setq string (read-from-minibuffer "Shell command on region: " nil nil nil (quote shell-command-history))) (list (region-beginning) (region-end) string current-prefix-arg current-prefix-arg shell-command-default-error-buffer t))],1 回答 (defun figlet-region (&optional b e) (interactive "r") (shell-command-on-region b e "figlet" (current-buffer) t) (comment-region (mark) (point))) (这是基于Trey Jackson的答案。) 示例(Lisp交互模式) ;; _ _ _ ;; | |_| |__ __ _ _ __ | | _____ ;; | __| '_ / _` | '_ | |/ / __| ;; | |_| | | | (_| | | | | <__ ;; __|_| |_|__,_|_| |_|_|____/ 示例(CPerl模式) # _ _ _ # | |_| |__ __ _ _ __ | | _____ # | __| '_ / _` | '_ | |/ / __| # | |_| | | | (_| | | | | <__ # __|_| |_|__,_|_| |_|_|____/
我不确定您正在尝试通过推出和弹出标记来完成什么,我相信通过这样做可以获得相同的功能:
(defun figlet-region (&optional b e) (interactive "r") (shell-command-on-region b e "figlet") (comment-region b e)) 交互的参数告诉Emacs将区域(点和标记)作为命令的前两个参数传递。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容