(defun find-library (library)
"Find the elisp source of LIBRARY."
(interactive
- (let* ((path (cons (or find-function-source-path load-path)
- (find-library-suffixes)))
+ (let* ((dirs (or find-function-source-path load-path))
+ (suffixes (find-library-suffixes))
(def (if (eq (function-called-at-point) 'require)
;; `function-called-at-point' may return 'require
;; with `point' anywhere on this line. So wrap the
(error nil))
(thing-at-point 'symbol))))
(when def
- (setq def (and (locate-file-completion def path 'test) def)))
+ (setq def (and (locate-file-completion-table
+ dirs suffixes def nil 'lambda)
+ def)))
(list
(completing-read (if def (format "Library name (default %s): " def)
"Library name: ")
- 'locate-file-completion path nil nil nil def))))
+ (apply-partially 'locate-file-completion-table
+ dirs suffixes)
+ nil nil nil nil def))))
(let ((buf (find-file-noselect (find-library-name library))))
(condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))
(if (memq 'readable predicate) 4 0))))
(locate-file-internal filename path suffixes predicate))
-(defun locate-file-completion (string path-and-suffixes action)
- "Do completion for file names passed to `locate-file'.
-PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)."
+(defun locate-file-completion-table (dirs suffixes string pred action)
+ "Do completion for file names passed to `locate-file'."
(if (file-name-absolute-p string)
- (read-file-name-internal string nil action)
+ (let ((read-file-name-predicate pred))
+ (read-file-name-internal string nil action))
(let ((names nil)
- (suffix (concat (regexp-opt (cdr path-and-suffixes) t) "\\'"))
+ (suffix (concat (regexp-opt suffixes t) "\\'"))
(string-dir (file-name-directory string)))
- (dolist (dir (car path-and-suffixes))
+ (dolist (dir dirs)
(unless dir
(setq dir default-directory))
(if string-dir (setq dir (expand-file-name string-dir dir)))
(when (string-match suffix file)
(setq file (substring file 0 (match-beginning 0)))
(push (if string-dir (concat string-dir file) file) names)))))
- (cond
- ((eq action t) (all-completions string names))
- ((null action) (try-completion string names))
- (t (test-completion string names))))))
+ (complete-with-action action names string pred))))
+
+(defun locate-file-completion (string path-and-suffixes action)
+ "Do completion for file names passed to `locate-file'.
+PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)."
+ (locate-file-completion-table (car path-and-suffixes)
+ (cdr path-and-suffixes)
+ string nil action))
+(make-obsolete 'locate-file-completion 'locate-file-completion-table "23.1")
(defun locate-dominating-file (file regexp)
"Look up the directory hierarchy from FILE for a file matching REGEXP."
This is an interface to the function `load'."
(interactive
(list (completing-read "Load library: "
- 'locate-file-completion
- (cons load-path (get-load-suffixes)))))
+ (apply-partially 'locate-file-completion-table
+ load-path
+ (get-load-suffixes)))))
(load library))
(defun file-remote-p (file &optional identification connected)
(if decoder
(progn
(insert-file-contents-literally fullname visit)
- (let ((buffer-read-only nil)
+ (let ((inhibit-read-only t)
(coding-system-for-write 'no-conversion)
(default-directory (or (file-name-directory fullname)
default-directory)))
where the match was found, and MODE is `major-mode' of the buffer in
which the match was found."
(let ((case-fold-search case-fold))
- (save-excursion
- (set-buffer (marker-buffer marker))
+ (with-current-buffer (marker-buffer marker)
(goto-char marker)
;; Search tag table
;; Switch files if necessary
(or (null filename)
(equal Info-current-file filename)
- (let ((buffer-read-only nil))
+ (let ((inhibit-read-only t))
(setq Info-current-file nil
Info-current-subfile nil
Info-current-file-completions nil
(or Info-tag-table-buffer
(generate-new-buffer " *info tag table*"))))
(setq Info-tag-table-buffer tagbuf)
- (save-excursion
- (set-buffer tagbuf)
+ (with-current-buffer tagbuf
(buffer-disable-undo (current-buffer))
(setq case-fold-search t)
(erase-buffer)
(cons (directory-file-name truename)
dirs-done)))
(if attrs
- (save-excursion
+ (with-current-buffer (generate-new-buffer " info dir")
(or buffers
(message "Composing main Info directory..."))
- (set-buffer (generate-new-buffer " info dir"))
(condition-case nil
(progn
(insert-file-contents file)
(let (lastfilepos
lastfilename)
(if (numberp nodepos)
- (save-excursion
- (set-buffer (marker-buffer Info-tag-table-marker))
+ (with-current-buffer (marker-buffer Info-tag-table-marker)
(goto-char (point-min))
(or (looking-at "\^_")
(search-forward "\n\^_"))
;; Assume previous buffer is in Info-mode.
;; (set-buffer (get-buffer "*info*"))
(or (equal Info-current-subfile lastfilename)
- (let ((buffer-read-only nil))
+ (let ((inhibit-read-only t))
(setq buffer-file-name nil)
(widen)
(erase-buffer)
(defvar Info-read-node-completion-table)
-(defun Info-read-node-name-2 (string path-and-suffixes action)
+(defun Info-read-node-name-2 (dirs suffixes string pred action)
"Virtual completion table for file names input in Info node names.
PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)."
- (let* ((names nil)
- (suffixes (remove "" (cdr path-and-suffixes)))
- (suffix (concat (regexp-opt suffixes t) "\\'"))
- (string-dir (file-name-directory string))
- (dirs
- (if (file-name-absolute-p string)
- (list (file-name-directory string))
- (car path-and-suffixes))))
+ (setq suffixes (remove "" suffixes))
+ (when (file-name-absolute-p string)
+ (setq dirs (list (file-name-directory string))))
+ (let ((names nil)
+ (suffix (concat (regexp-opt suffixes t) "\\'"))
+ (string-dir (file-name-directory string)))
(dolist (dir dirs)
(unless dir
(setq dir default-directory))
(when (string-match suffix file)
(setq file (substring file 0 (match-beginning 0)))
(push (if string-dir (concat string-dir file) file) names)))))
- (cond
- ((eq action t) (all-completions string names))
- ((null action) (try-completion string names))
- (t (test-completion string names)))))
+ (complete-with-action action names string pred)))
;; This function is used as the "completion table" while reading a node name.
;; It does completion using the alist in Info-read-node-completion-table
((string-match "\\`([^)]*\\'" string)
(completion-table-with-context
"("
- (apply-partially 'completion-table-with-terminator
- ")" 'Info-read-node-name-2)
+ (apply-partially 'completion-table-with-terminator ")"
+ (apply-partially 'Info-read-node-name-2
+ Info-directory-list
+ (mapcar 'car Info-suffix-list)))
(substring string 1)
- (cons Info-directory-list
- (mapcar 'car Info-suffix-list))
+ predicate
code))
;; If a file name was given, then any node is fair game.
(unwind-protect
;; Try other subfiles.
(let ((list ()))
- (save-excursion
- (set-buffer (marker-buffer Info-tag-table-marker))
+ (with-current-buffer (marker-buffer Info-tag-table-marker)
(goto-char (point-min))
(search-forward "\n\^_\nIndirect:")
(save-restriction
;; Note that `Info-complete-menu-buffer' could be current already,
;; so we want to save point.
- (save-excursion
- (set-buffer Info-complete-menu-buffer)
+ (with-current-buffer Info-complete-menu-buffer
(let ((completion-ignore-case t)
(case-fold-search t)
(orignode Info-current-node)
(defun Info-speedbar-fetch-file-nodes (nodespec)
"Fetch the subnodes from the info NODESPEC.
NODESPEC is a string of the form: (file)node."
- (save-excursion
- ;; Set up a buffer we can use to fake-out Info.
- (set-buffer (get-buffer-create " *info-browse-tmp*"))
+ ;; Set up a buffer we can use to fake-out Info.
+ (with-current-buffer (get-buffer-create " *info-browse-tmp*")
(if (not (equal major-mode 'Info-mode))
(Info-mode))
;; Get the node into this buffer