РЕДАКТИРОВАТЬ: неверно истолковать ваш вопрос как желание применить это изменение к файлу, над которым вы работаете.Если вы просто хотите запустить команду оболочки для буфера, вы можете использовать shell-command-on-region
, который обычно привязан к M-|
.
Если вы просто пытаетесь получить определенный номер строки, M-x goto-line
работает.Я связываю это с C-x C-l
, помещая (define-key global-map "\C-x\C-l" 'goto-line)
в мой ~/.emacs
.
Попробуйте это (в вашем ~/.emacs
файле):
;;; Run a shell command on all text between the mark and the point and
;;; replace with the output.
(defun shell-command-in-region (start end command &optional flag interactive)
"Execute shell-command-on-region and replace the region with the output
of the shell command."
(interactive (list (region-beginning) (region-end)
(read-from-minibuffer "Shell command in region: "
nil nil nil 'shell-command-history)
current-prefix-arg
(prefix-numeric-value current-prefix-arg)))
(shell-command-on-region (point) (mark) command t)
)
(define-key esc-map "#" 'shell-command-in-region)
Вызовите еговыбрав регион, над которым вы хотите работать, а затем выполните M-#
.