# HG changeset patch # User Kim F. Storm # Date 1120815887 0 # Node ID fad9662db4a977f6cc3e1d2297c4f324335e43aa # Parent e48f0695db75d2d9e48736973cb59db9b5f4e0dc (ido-before-fallback-functions): New hook. (ido-buffer-internal, ido-file-internal, ido-read-buffer) (ido-read-file-name): Run it. diff -r e48f0695db75 -r fad9662db4a9 lisp/ido.el --- a/lisp/ido.el Fri Jul 08 09:44:33 2005 +0000 +++ b/lisp/ido.el Fri Jul 08 09:44:47 2005 +0000 @@ -881,6 +881,12 @@ :type '(repeat symbol) :group 'ido) +(defcustom ido-before-fallback-functions '() + "List of functions to call before calling a fallback command. +The fallback command is passed as an argument to the functions." + :type 'hook + :group 'ido) + ;;; Internal Variables ;; Persistent variables @@ -1918,7 +1924,10 @@ (defun ido-buffer-internal (method &optional fallback prompt default initial switch-cmd) ;; Internal function for ido-switch-buffer and friends (if (not ido-mode) - (call-interactively (or fallback 'switch-to-buffer)) + (progn + (run-hook-with-args 'ido-before-fallback-functions + (or fallback 'switch-to-buffer)) + (call-interactively (or fallback 'switch-to-buffer))) (let* ((ido-context-switch-command switch-cmd) (ido-current-directory nil) (ido-directory-nonreadable nil) @@ -1937,6 +1946,8 @@ ((eq ido-exit 'fallback) (let ((read-buffer-function nil)) + (run-hook-with-args 'ido-before-fallback-functions + (or fallback 'switch-to-buffer)) (call-interactively (or fallback 'switch-to-buffer)))) ;; Check buf is non-nil. @@ -2068,6 +2079,8 @@ ;; we don't want to change directory of current buffer. (let ((default-directory ido-current-directory) (read-file-name-function nil)) + (run-hook-with-args 'ido-before-fallback-functions + (or fallback 'find-file)) (call-interactively (or fallback 'find-file)))) ((eq ido-exit 'switch-to-buffer) @@ -2134,6 +2147,7 @@ (setq filename (concat ido-current-directory filename)) (ido-record-command fallback filename) (ido-record-work-directory) + (run-hook-with-args 'ido-before-fallback-functions fallback) (funcall fallback filename)) ((eq method 'insert) @@ -4210,6 +4224,7 @@ (buf (ido-read-internal 'buffer prompt 'ido-buffer-history default require-match))) (if (eq ido-exit 'fallback) (let ((read-buffer-function nil)) + (run-hook-with-args 'ido-before-fallback-functions 'read-buffer) (read-buffer prompt default require-match)) buf))) @@ -4256,6 +4271,7 @@ (setq filename 'fallback))) (if (eq filename 'fallback) (let ((read-file-name-function nil)) + (run-hook-with-args 'ido-before-fallback-functions 'read-file-name) (read-file-name prompt dir default-filename mustmatch initial predicate)) filename)))