mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-04 11:40:22 +00:00
(ffap-read-file-or-url): Do not abuse completing-read's
`predicate' argument to pass non-predicate data. (ffap-read-url-internal, ffap-read-file-or-url-internal): Use second arg as proper predicate.
This commit is contained in:
parent
ec50e665d2
commit
984ddcbcef
@ -1,5 +1,10 @@
|
|||||||
2008-04-21 Stefan Monnier <monnier@iro.umontreal.ca>
|
2008-04-21 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||||
|
|
||||||
|
* ffap.el (ffap-read-file-or-url): Do not abuse completing-read's
|
||||||
|
`predicate' argument to pass non-predicate data.
|
||||||
|
(ffap-read-url-internal, ffap-read-file-or-url-internal):
|
||||||
|
Use second arg as proper predicate.
|
||||||
|
|
||||||
* vc-bzr.el (vc-bzr-complete-with-prefix): Remove.
|
* vc-bzr.el (vc-bzr-complete-with-prefix): Remove.
|
||||||
(vc-bzr-revision-completion-table): Use completion-table-with-context
|
(vc-bzr-revision-completion-table): Use completion-table-with-context
|
||||||
instead.
|
instead.
|
||||||
|
45
lisp/ffap.el
45
lisp/ffap.el
@ -922,7 +922,7 @@ If t, `ffap-tex-init' will initialize this when needed.")
|
|||||||
(ffap-locate-file name t ffap-bib-path))
|
(ffap-locate-file name t ffap-bib-path))
|
||||||
|
|
||||||
(defun ffap-dired (name)
|
(defun ffap-dired (name)
|
||||||
(let ((pt (point)) dir try)
|
(let ((pt (point)) try)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(and (progn
|
(and (progn
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
@ -1279,15 +1279,17 @@ which may actually result in an url rather than a filename."
|
|||||||
(push fnh-elem file-name-handler-alist)
|
(push fnh-elem file-name-handler-alist)
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(setq guess
|
(setq guess
|
||||||
(completing-read
|
(let ((default-directory (if dir (expand-file-name dir)
|
||||||
prompt
|
default-directory)))
|
||||||
'ffap-read-file-or-url-internal
|
(completing-read
|
||||||
dir
|
prompt
|
||||||
nil
|
'ffap-read-file-or-url-internal
|
||||||
(if dir (cons guess (length dir)) guess)
|
nil
|
||||||
(list 'file-name-history)
|
nil
|
||||||
(and buffer-file-name
|
(if dir (cons guess (length dir)) guess)
|
||||||
(abbreviate-file-name buffer-file-name))))
|
(list 'file-name-history)
|
||||||
|
(and buffer-file-name
|
||||||
|
(abbreviate-file-name buffer-file-name)))))
|
||||||
;; Remove the special handler manually. We used to just let-bind
|
;; Remove the special handler manually. We used to just let-bind
|
||||||
;; file-name-handler-alist to preserve its value, but that caused
|
;; file-name-handler-alist to preserve its value, but that caused
|
||||||
;; other modifications to be lost (e.g. when Tramp gets loaded
|
;; other modifications to be lost (e.g. when Tramp gets loaded
|
||||||
@ -1299,26 +1301,24 @@ which may actually result in an url rather than a filename."
|
|||||||
;; Note: upcoming url.el package ought to handle this automatically.
|
;; Note: upcoming url.el package ought to handle this automatically.
|
||||||
guess))
|
guess))
|
||||||
|
|
||||||
(defun ffap-read-url-internal (string dir action)
|
(defun ffap-read-url-internal (string pred action)
|
||||||
"Complete url's from history, treating given string as valid."
|
"Complete url's from history, treating given string as valid."
|
||||||
(let ((hist (ffap-soft-value "url-global-history-hash-table")))
|
(let ((hist (ffap-soft-value "url-global-history-hash-table")))
|
||||||
(cond
|
(cond
|
||||||
((not action)
|
((not action)
|
||||||
(or (try-completion string hist) string))
|
(or (try-completion string hist pred) string))
|
||||||
((eq action t)
|
((eq action t)
|
||||||
(or (all-completions string hist) (list string)))
|
(or (all-completions string hist pred) (list string)))
|
||||||
;; action == lambda, documented where? Tests whether string is a
|
;; action == lambda, documented where? Tests whether string is a
|
||||||
;; valid "match". Let us always say yes.
|
;; valid "match". Let us always say yes.
|
||||||
(t t))))
|
(t t))))
|
||||||
|
|
||||||
(defun ffap-read-file-or-url-internal (string dir action)
|
(defun ffap-read-file-or-url-internal (string pred action)
|
||||||
(unless dir
|
(unless string ;Why would this ever happen?
|
||||||
(setq dir default-directory))
|
|
||||||
(unless string
|
|
||||||
(setq string default-directory))
|
(setq string default-directory))
|
||||||
(if (ffap-url-p string)
|
(if (ffap-url-p string)
|
||||||
(ffap-read-url-internal string dir action)
|
(ffap-read-url-internal string pred action)
|
||||||
(read-file-name-internal string dir action)))
|
(read-file-name-internal string pred action)))
|
||||||
|
|
||||||
;; The rest of this page is just to work with package complete.el.
|
;; The rest of this page is just to work with package complete.el.
|
||||||
;; This code assumes that you load ffap.el after complete.el.
|
;; This code assumes that you load ffap.el after complete.el.
|
||||||
@ -1523,7 +1523,7 @@ Function CONT is applied to the entry chosen by the user."
|
|||||||
(x-popup-menu
|
(x-popup-menu
|
||||||
t
|
t
|
||||||
(list "" (cons title
|
(list "" (cons title
|
||||||
(mapcar (function (lambda (i) (cons (car i) i)))
|
(mapcar (lambda (i) (cons (car i) i))
|
||||||
alist))))))
|
alist))))))
|
||||||
;; minibuffer with completion buffer:
|
;; minibuffer with completion buffer:
|
||||||
(t
|
(t
|
||||||
@ -1537,8 +1537,7 @@ Function CONT is applied to the entry chosen by the user."
|
|||||||
nil)))
|
nil)))
|
||||||
(sit-for 0) ; redraw original screen
|
(sit-for 0) ; redraw original screen
|
||||||
;; Convert string to its entry, or else the default:
|
;; Convert string to its entry, or else the default:
|
||||||
(setq choice (or (assoc choice alist) (car alist))))
|
(setq choice (or (assoc choice alist) (car alist)))))
|
||||||
)
|
|
||||||
(if choice
|
(if choice
|
||||||
(funcall cont choice)
|
(funcall cont choice)
|
||||||
(message "No choice made!") ; possible with menus
|
(message "No choice made!") ; possible with menus
|
||||||
@ -1569,7 +1568,7 @@ Applies `ffap-menu-text-plist' text properties at all matches."
|
|||||||
ffap-menu-text-plist)
|
ffap-menu-text-plist)
|
||||||
(message "Scanning...%2d%% <%s>"
|
(message "Scanning...%2d%% <%s>"
|
||||||
(/ (* 100 (- (point) (point-min))) range) item)))
|
(/ (* 100 (- (point) (point-min))) range) item)))
|
||||||
(or mod (set-buffer-modified-p nil))))
|
(or mod (restore-buffer-modified-p nil))))
|
||||||
(message "Scanning...done")
|
(message "Scanning...done")
|
||||||
;; Remove duplicates.
|
;; Remove duplicates.
|
||||||
(setq ffap-menu-alist ; sort by item
|
(setq ffap-menu-alist ; sort by item
|
||||||
|
Loading…
Reference in New Issue
Block a user