diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2019-07-14 19:17:36 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2019-07-14 19:17:41 +0200 |
commit | 284e6cf9a41a57ab44003713940c75891cda8f6a (patch) | |
tree | e1f98957d1fa5cce777af783c038955590cf8673 /lisp/ffap.el | |
parent | 783eca57159065ea575622b74e1446853f31621a (diff) | |
download | emacs-284e6cf9a41a57ab44003713940c75891cda8f6a.tar.gz |
Fix prompting in functions like ffap-read-only
* lisp/ffap.el (ffap-prompter, ffap-other-window)
(ffap-other-frame, ffap-read-only)
(ffap-read-only-other-window, ffap-read-only-other-frame)
(ffap-alternate-file, ffap-alternate-file-other-window)
(ffap-literally): Rework to be able to specify different prompts
for different actions (bug#30284) and don't use
`call-interactively' all over the place.
Diffstat (limited to 'lisp/ffap.el')
-rw-r--r-- | lisp/ffap.el | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/lisp/ffap.el b/lisp/ffap.el index 08f72089450..47ceed47e3e 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -1513,7 +1513,7 @@ Uses the face `ffap' if it is defined, or else `highlight'." (ffap-file-at-point) ; may yield url! (ffap-fixup-machine (ffap-machine-at-point)))) -(defun ffap-prompter (&optional guess) +(defun ffap-prompter (&optional guess suffix) ;; Does guess and prompt step for find-file-at-point. ;; Extra complication for the temporary highlighting. (unwind-protect @@ -1521,7 +1521,9 @@ Uses the face `ffap' if it is defined, or else `highlight'." ;; and then maybe skip over this prompt (ff-paths, for example). (catch 'ffap-prompter (ffap-read-file-or-url - (if ffap-url-regexp "Find file or URL: " "Find file: ") + (if ffap-url-regexp + (format "Find file or URL%s: " (or suffix "")) + (format "Find file%s: " (or suffix ""))) (prog1 (let ((mark-active nil)) ;; Don't use the region here, since it can be something @@ -1768,18 +1770,18 @@ Return value: ;; at least two new user variables, and there is no w3-fetch-noselect. ;; So instead, we just fake it with a slow save-window-excursion. -(defun ffap-other-window () +(defun ffap-other-window (filename) "Like `ffap', but put buffer in another window. Only intended for interactive use." - (interactive) - (pcase (save-window-excursion (call-interactively 'ffap)) + (interactive (list (ffap-prompter nil " other window"))) + (pcase (save-window-excursion (find-file-at-point filename)) ((or (and (pred bufferp) b) `(,(and (pred bufferp) b) . ,_)) (switch-to-buffer-other-window b)))) -(defun ffap-other-frame () +(defun ffap-other-frame (filename) "Like `ffap', but put buffer in another frame. Only intended for interactive use." - (interactive) + (interactive (list (ffap-prompter nil " other frame"))) ;; Extra code works around dedicated windows (noted by JENS, 7/96): (let* ((win (selected-window)) (wdp (window-dedicated-p win)) @@ -1789,7 +1791,7 @@ Only intended for interactive use." (set-window-dedicated-p win nil) (switch-to-buffer-other-frame (save-window-excursion - (setq value (call-interactively 'ffap)) + (setq value (find-file-at-point filename)) (unless (or (bufferp value) (bufferp (car-safe value))) (setq value (current-buffer))) (current-buffer)))) @@ -1803,52 +1805,52 @@ Only intended for interactive use." (with-current-buffer buffer (read-only-mode 1)))) -(defun ffap-read-only () +(defun ffap-read-only (filename) "Like `ffap', but mark buffer as read-only. Only intended for interactive use." - (interactive) - (let ((value (call-interactively 'ffap))) + (interactive (list (ffap-prompter nil " read only"))) + (let ((value (find-file-at-point filename))) (unless (or (bufferp value) (bufferp (car-safe value))) (setq value (current-buffer))) (ffap--toggle-read-only value) value)) -(defun ffap-read-only-other-window () +(defun ffap-read-only-other-window (filename) "Like `ffap', but put buffer in another window and mark as read-only. Only intended for interactive use." - (interactive) - (let ((value (ffap-other-window))) + (interactive (list (ffap-prompter nil " read only other window"))) + (let ((value (ffap-other-window filename))) (ffap--toggle-read-only value) value)) -(defun ffap-read-only-other-frame () +(defun ffap-read-only-other-frame (filename) "Like `ffap', but put buffer in another frame and mark as read-only. Only intended for interactive use." - (interactive) - (let ((value (ffap-other-frame))) + (interactive (list (ffap-prompter nil " read only other frame"))) + (let ((value (ffap-other-frame filename))) (ffap--toggle-read-only value) value)) -(defun ffap-alternate-file () +(defun ffap-alternate-file (filename) "Like `ffap' and `find-alternate-file'. Only intended for interactive use." - (interactive) + (interactive (list (ffap-prompter nil " alternate file"))) (let ((ffap-file-finder 'find-alternate-file)) - (call-interactively 'ffap))) + (find-file-at-point filename))) -(defun ffap-alternate-file-other-window () +(defun ffap-alternate-file-other-window (filename) "Like `ffap' and `find-alternate-file-other-window'. Only intended for interactive use." - (interactive) + (interactive (list (ffap-prompter nil " alternate file other window"))) (let ((ffap-file-finder 'find-alternate-file-other-window)) - (call-interactively 'ffap))) + (find-file-at-point filename))) -(defun ffap-literally () +(defun ffap-literally (filename) "Like `ffap' and command `find-file-literally'. Only intended for interactive use." - (interactive) + (interactive (list (ffap-prompter nil " literally"))) (let ((ffap-file-finder 'find-file-literally)) - (call-interactively 'ffap))) + (find-file-at-point filename))) (defalias 'find-file-literally-at-point 'ffap-literally) |