【发布时间】:2010-08-26 04:33:31
【问题描述】:
我有以下代码运行 figlet,其输入为范围。 如何修改此代码以检查是否未指定 b 或 e,将 b 设为当前缓冲区的开头,将 e 设为当前缓冲区的结尾?
(defun figlet-region (&optional b e)
(interactive "r")
(shell-command-on-region b e "/opt/local/bin/figlet" (current-buffer) t)
(comment-region (mark) (point)))
(global-set-key (kbd "C-c C-x") 'figlet-region)
添加
肖恩帮我找到了这个问题的答案
(defun figlet-region (&optional b e)
(interactive)
(let ((b (if mark-active (min (point) (mark)) (point-min)))
(e (if mark-active (max (point) (mark)) (point-max))))
(shell-command-on-region b e "/opt/local/bin/figlet" (current-buffer) t)
(comment-region (mark) (point))))
(global-set-key (kbd "C-c C-x") 'figlet-region)
【问题讨论】: