all repos — nixfiles @ 83923895305252c639019ffa2e0270f5cc54f614

System and user configuration, managed by nix and home-manager

Emacs: make shell-execute work when buffer is not visiting a file
Alan Pearce alan@alanpearce.co.uk
Tue, 28 May 2013 19:09:11 +0100
commit

83923895305252c639019ffa2e0270f5cc54f614

parent

d46e831026aeff0f6577edab0a3accfbecc68d0b

1 files changed, 3 insertions(+), 1 deletions(-)

jump to
M emacs/elisp/ap-functions.elemacs/elisp/ap-functions.el
@@ -39,6 +39,8 @@ ;;;###autoload
 (defun shell-execute ()
   (interactive)
-  (let ((file-buffer (or (file-name-nondirectory (buffer-file-name)) ""))
+  (let ((file-buffer (if (buffer-file-name)
+                         (file-name-nondirectory (buffer-file-name))
+                       ""))
         (command (read-shell-command "Shell command: " nil nil nil)))
     (shell-command (replace-regexp-in-string "%" file-buffer command))))