aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJoakim Verona2015-01-20 00:54:09 +0100
committerJoakim Verona2015-01-20 00:54:09 +0100
commitfee879f0a00bbe3f3389509874ee30a9cbc24cd4 (patch)
tree5bc4dc325818bec8a6a4cf20b1c907d23e24425a /lisp
parent395a90fee92a836f55df0b879f8ee3d862d648ac (diff)
parentfb6462f056f616f3da8ae18037c7c2137fecb6fd (diff)
downloademacs-fee879f0a00bbe3f3389509874ee30a9cbc24cd4.tar.gz
emacs-fee879f0a00bbe3f3389509874ee30a9cbc24cd4.zip
Merge branch 'master' into xwidget
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog79
-rw-r--r--lisp/cus-dep.el3
-rw-r--r--lisp/emacs-lisp/cl-generic.el27
-rw-r--r--lisp/emacs-lisp/eieio-core.el25
-rw-r--r--lisp/emacs-lisp/eieio-generic.el2
-rw-r--r--lisp/emacs-lisp/eieio.el11
-rw-r--r--lisp/emacs-lisp/package.el14
-rw-r--r--lisp/ido.el233
-rw-r--r--lisp/progmodes/xref.el56
9 files changed, 294 insertions, 156 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 680adc71d0a..b1a3a73864c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,74 @@
12015-01-19 Dmitry Gutov <dgutov@yandex.ru>
2
3 * ido.el: Update Customization instructions.
4
52015-01-19 Jonas Bernoulli <jonas@bernoul.li>
6
7 Define Ido keymaps once (bug#17000).
8 * ido.el (ido-common-completion-map)
9 (ido-file-dir-completion-map)
10 (ido-file-completion-map, ido-buffer-completion-map): Set up key
11 bindings when each variable is defined.
12 (ido-completion-map): Move definition.
13 (ido-init-completion-maps): Noop.
14 (ido-common-initialization): Don't call it.
15 (ido-setup-completion-map): Improve doc-string, cleanup.
16
172015-01-19 Ivan Shmakov <ivan@siamics.net>
18
19 * cus-dep.el (custom-make-dependencies): Ensure that
20 default-directory is interpreted as a directory (see bug#19140.)
21
222015-01-19 Dmitry Gutov <dgutov@yandex.ru>
23
24 * progmodes/xref.el (xref--display-position):
25 Set `other-window-scroll-buffer'.
26 (xref-goto-xref): Use `user-error'.
27
282015-01-19 Dmitry Gutov <dgutov@yandex.ru>
29
30 * progmodes/xref.el (xref--display-history): New variable.
31 (xref--window-configuration): Remove.
32 (xref--save-to-history): New function.
33 (xref--display-position): Use it. Add new argument.
34 (xref--restore-window-configuration): Remove.
35 (xref--show-location, xref-show-location-at-point): Update
36 accordingly.
37 (xref--xref-buffer-mode): Don't use `pre-command-hook'.
38 (xref--quit): New command.
39 (xref-goto-xref): Use it.
40 (xref--xref-buffer-mode-map): Bind `q' to it.
41
422015-01-18 Dmitry Gutov <dgutov@yandex.ru>
43
44 * progmodes/xref.el (xref-goto-xref): Perform the jump even inside
45 indentation or at eol.
46
472015-01-18 Stefan Monnier <monnier@iro.umontreal.ca>
48
49 * emacs-lisp/eieio-core.el: Add `subclass' specializer for cl-generic.
50 (eieio--generic-subclass-tagcode, eieio--generic-subclass-tag-types):
51 New functions.
52 (cl-generic-tagcode-function, cl-generic-tag-types-function): Use them.
53
54 * emacs-lisp/eieio.el (defclass): Add obsolescence warning for the
55 `newname' argument.
56
57 * emacs-lisp/cl-generic.el (cl-generic-define-method): Correctly handle
58 introduction of a new dispatch argument.
59 (cl--generic-cache-miss): Handle dispatch on an argument which was not
60 considered as dispatchable for this method.
61 (cl-defmethod): Warn when adding a method to an obsolete generic function.
62 (cl--generic-lambda): Make sure it works if cl-lib is not yet loaded.
63
64 * emacs-lisp/eieio-generic.el (eieio--defgeneric-init-form): Use autoloadp.
65
662015-01-18 Artur Malabarba <bruce.connor.am@gmail.com>
67
68 * emacs-lisp/package.el (package--append-to-alist): Rename from
69 `package--add-to-alist'
70 Updated docstring due to new name.
71
12015-01-18 Leo Liu <sdl.web@gmail.com> 722015-01-18 Leo Liu <sdl.web@gmail.com>
2 73
3 * emacs-lisp/cl-extra.el (cl-subseq): Use seq-subseq and fix 74 * emacs-lisp/cl-extra.el (cl-subseq): Use seq-subseq and fix
@@ -132,8 +203,8 @@
1322015-01-16 Artur Malabarba <bruce.connor.am@gmail.com> 2032015-01-16 Artur Malabarba <bruce.connor.am@gmail.com>
133 204
134 * emacs-lisp/package.el (package--read-pkg-desc): 205 * emacs-lisp/package.el (package--read-pkg-desc):
135 New function. Read a `define-package' form in current buffer. Return 206 New function. Read a `define-package' form in current buffer.
136 the pkg-desc, with desc-kind set to KIND. 207 Return the pkg-desc, with desc-kind set to KIND.
137 (package-dir-info): New function. Find package information for a 208 (package-dir-info): New function. Find package information for a
138 directory. The return result is a `package-desc'. 209 directory. The return result is a `package-desc'.
139 (package-install-from-buffer): Install packages from dired buffer. 210 (package-install-from-buffer): Install packages from dired buffer.
@@ -856,8 +927,8 @@
8562014-12-27 Eli Zaretskii <eliz@gnu.org> 9272014-12-27 Eli Zaretskii <eliz@gnu.org>
857 928
858 * language/misc-lang.el (composition-function-table): Add Syriac 929 * language/misc-lang.el (composition-function-table): Add Syriac
859 characters and also ZWJ/ZWNJ. See 930 characters and also ZWJ/ZWNJ.
860 http://lists.gnu.org/archive/html/help-gnu-emacs/2014-12/msg00248.html 931 See http://lists.gnu.org/archive/html/help-gnu-emacs/2014-12/msg00248.html
861 for the details. 932 for the details.
862 933
8632014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org> 9342014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org>
diff --git a/lisp/cus-dep.el b/lisp/cus-dep.el
index 453b15ddcea..b8a9eb82655 100644
--- a/lisp/cus-dep.el
+++ b/lisp/cus-dep.el
@@ -62,7 +62,8 @@ Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS"
62 (while (setq subdir (pop command-line-args-left)) 62 (while (setq subdir (pop command-line-args-left))
63 (message "Directory %s" subdir) 63 (message "Directory %s" subdir)
64 (let ((files (directory-files subdir nil "\\`[^=.].*\\.el\\'")) 64 (let ((files (directory-files subdir nil "\\`[^=.].*\\.el\\'"))
65 (default-directory (expand-file-name subdir)) 65 (default-directory
66 (file-name-as-directory (expand-file-name subdir)))
66 (preloaded (concat "\\`\\(\\./+\\)?" 67 (preloaded (concat "\\`\\(\\./+\\)?"
67 (regexp-opt preloaded-file-list t) 68 (regexp-opt preloaded-file-list t)
68 "\\.el\\'"))) 69 "\\.el\\'")))
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 819e2e92888..544f1fa140f 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -212,13 +212,13 @@ This macro can only be used within the lexical scope of a cl-generic method."
212 (macroenv (cons `(cl-generic-current-method-specializers 212 (macroenv (cons `(cl-generic-current-method-specializers
213 . ,(lambda () specializers)) 213 . ,(lambda () specializers))
214 macroexpand-all-environment))) 214 macroexpand-all-environment)))
215 (require 'cl-lib) ;Needed to expand `cl-flet' and `cl-function'.
215 (if (not with-cnm) 216 (if (not with-cnm)
216 (cons nil (macroexpand-all fun macroenv)) 217 (cons nil (macroexpand-all fun macroenv))
217 ;; First macroexpand away the cl-function stuff (e.g. &key and 218 ;; First macroexpand away the cl-function stuff (e.g. &key and
218 ;; destructuring args, `declare' and whatnot). 219 ;; destructuring args, `declare' and whatnot).
219 (pcase (macroexpand fun macroenv) 220 (pcase (macroexpand fun macroenv)
220 (`#'(lambda ,args . ,body) 221 (`#'(lambda ,args . ,body)
221 (require 'cl-lib) ;Needed to expand `cl-flet'.
222 (let* ((doc-string (and doc-string (stringp (car body)) 222 (let* ((doc-string (and doc-string (stringp (car body))
223 (pop body))) 223 (pop body)))
224 (cnm (make-symbol "cl--cnm")) 224 (cnm (make-symbol "cl--cnm"))
@@ -287,6 +287,13 @@ which case this method will be invoked when the argument is `eql' to VAL.
287 (cadr name)))) 287 (cadr name))))
288 (setq name setter) 288 (setq name setter)
289 code)) 289 code))
290 ,(and (get name 'byte-obsolete-info)
291 (or (not (fboundp 'byte-compile-warning-enabled-p))
292 (byte-compile-warning-enabled-p 'obsolete))
293 (let* ((obsolete (get name 'byte-obsolete-info)))
294 (macroexp--warn-and-return
295 (macroexp--obsolete-warning name obsolete "generic function")
296 nil)))
290 (cl-generic-define-method ',name ',qualifiers ',args 297 (cl-generic-define-method ',name ',qualifiers ',args
291 ,uses-cnm ,fun))))) 298 ,uses-cnm ,fun)))))
292 299
@@ -308,13 +315,14 @@ which case this method will be invoked when the argument is `eql' to VAL.
308 (dolist (specializer specializers) 315 (dolist (specializer specializers)
309 (let* ((tagcode (funcall cl-generic-tagcode-function specializer 'arg)) 316 (let* ((tagcode (funcall cl-generic-tagcode-function specializer 'arg))
310 (x (assq i dispatches))) 317 (x (assq i dispatches)))
311 (if (not x) 318 (unless x
312 (setf (cl--generic-dispatches generic) 319 (setq x (list i (funcall cl-generic-tagcode-function t 'arg)))
313 (setq dispatches (cons (list i tagcode) dispatches))) 320 (setf (cl--generic-dispatches generic)
314 (unless (member tagcode (cdr x)) 321 (setq dispatches (cons x dispatches))))
315 (setf (cdr x) 322 (unless (member tagcode (cdr x))
316 (nreverse (sort (cons tagcode (cdr x)) 323 (setf (cdr x)
317 #'car-less-than-car))))) 324 (nreverse (sort (cons tagcode (cdr x))
325 #'car-less-than-car))))
318 (setq i (1+ i)))) 326 (setq i (1+ i))))
319 (if me (setcdr me (cons uses-cnm function)) 327 (if me (setcdr me (cons uses-cnm function))
320 (setf (cl--generic-method-table generic) 328 (setf (cl--generic-method-table generic)
@@ -478,7 +486,8 @@ for all those different tags in the method-cache.")
478 (let ((types (apply #'append (mapcar cl-generic-tag-types-function tags))) 486 (let ((types (apply #'append (mapcar cl-generic-tag-types-function tags)))
479 (methods '())) 487 (methods '()))
480 (dolist (method-desc (cl--generic-method-table generic)) 488 (dolist (method-desc (cl--generic-method-table generic))
481 (let ((m (member (nth dispatch-arg (caar method-desc)) types))) 489 (let* ((specializer (or (nth dispatch-arg (caar method-desc)) t))
490 (m (member specializer types)))
482 (when m 491 (when m
483 (push (cons (length m) method-desc) methods)))) 492 (push (cons (length m) method-desc) methods))))
484 ;; Sort the methods, most specific first. 493 ;; Sort the methods, most specific first.
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index a82e887fa0c..e4221e48fe2 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -1227,6 +1227,8 @@ method invocation orders of the involved classes."
1227 1227
1228(require 'cl-generic) 1228(require 'cl-generic)
1229 1229
1230;;;; General support to dispatch based on the type of the argument.
1231
1230(add-function :before-until cl-generic-tagcode-function 1232(add-function :before-until cl-generic-tagcode-function
1231 #'eieio--generic-tagcode) 1233 #'eieio--generic-tagcode)
1232(defun eieio--generic-tagcode (type name) 1234(defun eieio--generic-tagcode (type name)
@@ -1246,6 +1248,29 @@ method invocation orders of the involved classes."
1246 (mapcar #'eieio--class-symbol 1248 (mapcar #'eieio--class-symbol
1247 (eieio--class-precedence-list (symbol-value tag))))) 1249 (eieio--class-precedence-list (symbol-value tag)))))
1248 1250
1251;;;; Dispatch for arguments which are classes.
1252
1253;; Since EIEIO does not support metaclasses, users can't easily use the
1254;; "dispatch on argument type" for class arguments. That's why EIEIO's
1255;; `defmethod' added the :static qualifier. For cl-generic, such a qualifier
1256;; would not make much sense (e.g. to which argument should it apply?).
1257;; Instead, we add a new "subclass" specializer.
1258
1259(add-function :before-until cl-generic-tagcode-function
1260 #'eieio--generic-subclass-tagcode)
1261(defun eieio--generic-subclass-tagcode (type name)
1262 (when (eq 'subclass (car-safe type))
1263 `(60 . (and (symbolp ,name) (eieio--class-v ,name)))))
1264
1265(add-function :before-until cl-generic-tag-types-function
1266 #'eieio--generic-subclass-tag-types)
1267(defun eieio--generic-subclass-tag-types (tag)
1268 (when (eieio--class-p tag)
1269 (mapcar (lambda (class)
1270 `(subclass
1271 ,(if (symbolp class) class (eieio--class-symbol class))))
1272 (eieio--class-precedence-list tag))))
1273
1249;;; Backward compatibility functions 1274;;; Backward compatibility functions
1250;; To support .elc files compiled for older versions of EIEIO. 1275;; To support .elc files compiled for older versions of EIEIO.
1251 1276
diff --git a/lisp/emacs-lisp/eieio-generic.el b/lisp/emacs-lisp/eieio-generic.el
index 27a58493905..74ecefe7863 100644
--- a/lisp/emacs-lisp/eieio-generic.el
+++ b/lisp/emacs-lisp/eieio-generic.el
@@ -110,7 +110,7 @@ Methods with only primary implementations are executed in an optimized way."
110 110
111 (cond 111 (cond
112 ((or (not (fboundp method)) 112 ((or (not (fboundp method))
113 (eq 'autoload (car-safe (symbol-function method)))) 113 (autoloadp (symbol-function method)))
114 ;; Make sure the method tables are installed. 114 ;; Make sure the method tables are installed.
115 (eieio--mt-install method) 115 (eieio--mt-install method)
116 ;; Construct the actual body of this function. 116 ;; Construct the actual body of this function.
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index c5597b83170..0c85d90151a 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -276,6 +276,17 @@ and reference them using the function `class-option'."
276 `(defun ,name (&rest slots) 276 `(defun ,name (&rest slots)
277 ,(format "Create a new object with name NAME of class type %S." 277 ,(format "Create a new object with name NAME of class type %S."
278 name) 278 name)
279 (declare (compiler-macro
280 (lambda (whole)
281 (if (not (stringp (car slots)))
282 whole
283 (macroexp--warn-and-return
284 (format "Obsolete name arg %S to constructor %S"
285 (car slots) (car whole))
286 ;; Keep the name arg, for backward compatibility,
287 ;; but hide it so we don't trigger indefinitely.
288 `(,(car whole) (identity ,(car slots))
289 ,@(cdr slots)))))))
279 (apply #'eieio-constructor ',name slots)))))) 290 (apply #'eieio-constructor ',name slots))))))
280 291
281 292
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 4be3b584a72..0f094b556ba 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1154,13 +1154,15 @@ Also, add the originating archive to the `package-desc' structure."
1154 (when (not (and pinned-to-archive 1154 (when (not (and pinned-to-archive
1155 (not (equal (cdr pinned-to-archive) archive)))) 1155 (not (equal (cdr pinned-to-archive) archive))))
1156 (setq package-archive-contents 1156 (setq package-archive-contents
1157 (package--add-to-alist pkg-desc package-archive-contents))))) 1157 (package--append-to-alist pkg-desc package-archive-contents)))))
1158 1158
1159(defun package--add-to-alist (pkg-desc alist) 1159(defun package--append-to-alist (pkg-desc alist)
1160 "Add PKG-DESC to ALIST. 1160 "Append an entry for PKG-DESC to the start of ALIST and return it.
1161This entry takes the form (`package-desc-name' PKG-DESC).
1161 1162
1162Packages are grouped by name. The package descriptions are sorted 1163If ALIST already has an entry with this name, destructively add
1163by version number." 1164PKG-DESC to the cdr of this entry instead, sorted by version
1165number."
1164 (let* ((name (package-desc-name pkg-desc)) 1166 (let* ((name (package-desc-name pkg-desc))
1165 (priority-version (package-desc-priority-version pkg-desc)) 1167 (priority-version (package-desc-priority-version pkg-desc))
1166 (existing-packages (assq name alist))) 1168 (existing-packages (assq name alist)))
@@ -2100,7 +2102,7 @@ If optional arg BUTTON is non-nil, describe its associated package."
2100 (cond ((member status '("installed" "unsigned")) 2102 (cond ((member status '("installed" "unsigned"))
2101 (push pkg-desc installed)) 2103 (push pkg-desc installed))
2102 ((member status '("available" "new")) 2104 ((member status '("available" "new"))
2103 (setq available (package--add-to-alist pkg-desc available)))))) 2105 (setq available (package--append-to-alist pkg-desc available))))))
2104 ;; Loop through list of installed packages, finding upgrades. 2106 ;; Loop through list of installed packages, finding upgrades.
2105 (dolist (pkg-desc installed) 2107 (dolist (pkg-desc installed)
2106 (let* ((name (package-desc-name pkg-desc)) 2108 (let* ((name (package-desc-name pkg-desc))
diff --git a/lisp/ido.el b/lisp/ido.el
index 2321b57d08a..1f4e3facd36 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -208,13 +208,13 @@
208;; 208;;
209;; Customize the Ido group to change the Ido functionality. 209;; Customize the Ido group to change the Ido functionality.
210;; 210;;
211;; To modify the keybindings, use the ido-setup-hook. For example: 211;; To modify the keybindings, use `define-key' on
212;;(add-hook 'ido-setup-hook 'ido-my-keys) 212;; `ido-common-completion-map' or one of the specialized keymaps:
213;; `ido-file-dir-completion-map', `ido-file-completion-map' or
214;; `ido-buffer-completion-map'.
213;; 215;;
214;;(defun ido-my-keys () 216;; (with-eval-after-load 'ido
215;; "Add my keybindings for ido." 217;; (define-key ido-common-completion-map " " 'ido-next-match))
216;; (define-key ido-completion-map " " 'ido-next-match)
217;; )
218 218
219;; Seeing all the matching buffers or files 219;; Seeing all the matching buffers or files
220;; ---------------------------------------- 220;; ----------------------------------------
@@ -323,8 +323,8 @@
323 323
324(defvar recentf-list) 324(defvar recentf-list)
325 325
326;;; User Variables 326;;;; Options
327;; 327
328;; These are some things you might want to change. 328;; These are some things you might want to change.
329 329
330(defun ido-fractionp (n) 330(defun ido-fractionp (n)
@@ -978,25 +978,90 @@ The fallback command is passed as an argument to the functions."
978 :type 'hook 978 :type 'hook
979 :group 'ido) 979 :group 'ido)
980 980
981;;; Internal Variables 981;;;; Keymaps
982
983;; Persistent variables
984
985(defvar ido-completion-map nil
986 "Currently active keymap for Ido commands.")
987 982
988(defvar ido-common-completion-map nil 983(defvar ido-common-completion-map
984 (let ((map (make-sparse-keymap)))
985 (set-keymap-parent map minibuffer-local-map)
986 (define-key map "\C-a" 'ido-toggle-ignore)
987 (define-key map "\C-c" 'ido-toggle-case)
988 (define-key map "\C-e" 'ido-edit-input)
989 (define-key map "\t" 'ido-complete)
990 (define-key map " " 'ido-complete-space)
991 (define-key map "\C-j" 'ido-select-text)
992 (define-key map "\C-m" 'ido-exit-minibuffer)
993 (define-key map "\C-p" 'ido-toggle-prefix)
994 (define-key map "\C-r" 'ido-prev-match)
995 (define-key map "\C-s" 'ido-next-match)
996 (define-key map [?\C-.] 'ido-next-match)
997 (define-key map [?\C-,] 'ido-prev-match)
998 (define-key map "\C-t" 'ido-toggle-regexp)
999 (define-key map "\C-z" 'ido-undo-merge-work-directory)
1000 (define-key map [(control ?\s)] 'ido-restrict-to-matches)
1001 (define-key map [(meta ?\s)] 'ido-take-first-match)
1002 (define-key map [(control ?@)] 'ido-restrict-to-matches)
1003 (define-key map [right] 'ido-next-match)
1004 (define-key map [left] 'ido-prev-match)
1005 (define-key map "?" 'ido-completion-help)
1006 (define-key map "\C-b" 'ido-magic-backward-char)
1007 (define-key map "\C-f" 'ido-magic-forward-char)
1008 (define-key map "\C-d" 'ido-magic-delete-char)
1009 map)
989 "Keymap for all Ido commands.") 1010 "Keymap for all Ido commands.")
990 1011
991(defvar ido-file-completion-map nil 1012(defvar ido-file-dir-completion-map
992 "Keymap for Ido file commands.") 1013 (let ((map (make-sparse-keymap)))
993 1014 (set-keymap-parent map ido-common-completion-map)
994(defvar ido-file-dir-completion-map nil 1015 (define-key map "\C-x\C-b" 'ido-enter-switch-buffer)
1016 (define-key map "\C-x\C-f" 'ido-fallback-command)
1017 (define-key map "\C-x\C-d" 'ido-enter-dired)
1018 (define-key map [down] 'ido-next-match-dir)
1019 (define-key map [up] 'ido-prev-match-dir)
1020 (define-key map [(meta up)] 'ido-prev-work-directory)
1021 (define-key map [(meta down)] 'ido-next-work-directory)
1022 (define-key map [backspace] 'ido-delete-backward-updir)
1023 (define-key map "\d" 'ido-delete-backward-updir)
1024 (define-key map [remap delete-backward-char] 'ido-delete-backward-updir) ; BS
1025 (define-key map [remap backward-kill-word] 'ido-delete-backward-word-updir) ; M-DEL
1026 (define-key map [(control backspace)] 'ido-up-directory)
1027 (define-key map "\C-l" 'ido-reread-directory)
1028 (define-key map [(meta ?d)] 'ido-wide-find-dir-or-delete-dir)
1029 (define-key map [(meta ?b)] 'ido-push-dir)
1030 (define-key map [(meta ?v)] 'ido-push-dir-first)
1031 (define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir)
1032 (define-key map [(meta ?k)] 'ido-forget-work-directory)
1033 (define-key map [(meta ?m)] 'ido-make-directory)
1034 (define-key map [(meta ?n)] 'ido-next-work-directory)
1035 (define-key map [(meta ?o)] 'ido-prev-work-file)
1036 (define-key map [(meta control ?o)] 'ido-next-work-file)
1037 (define-key map [(meta ?p)] 'ido-prev-work-directory)
1038 (define-key map [(meta ?s)] 'ido-merge-work-directories)
1039 map)
995 "Keymap for Ido file and directory commands.") 1040 "Keymap for Ido file and directory commands.")
996 1041
997(defvar ido-buffer-completion-map nil 1042(defvar ido-file-completion-map
1043 (let ((map (make-sparse-keymap)))
1044 (set-keymap-parent map ido-file-dir-completion-map)
1045 (define-key map "\C-k" 'ido-delete-file-at-head)
1046 (define-key map "\C-o" 'ido-copy-current-word)
1047 (define-key map "\C-w" 'ido-copy-current-file-name)
1048 (define-key map [(meta ?l)] 'ido-toggle-literal)
1049 map)
1050 "Keymap for Ido file commands.")
1051
1052(defvar ido-buffer-completion-map
1053 (let ((map (make-sparse-keymap)))
1054 (set-keymap-parent map ido-common-completion-map)
1055 (define-key map "\C-x\C-f" 'ido-enter-find-file)
1056 (define-key map "\C-x\C-b" 'ido-fallback-command)
1057 (define-key map "\C-k" 'ido-kill-buffer-at-head)
1058 (define-key map [?\C-\S-b] 'ido-bury-buffer-at-head)
1059 (define-key map "\C-o" 'ido-toggle-virtual-buffers)
1060 map)
998 "Keymap for Ido buffer commands.") 1061 "Keymap for Ido buffer commands.")
999 1062
1063;;;; Persistent variables
1064
1000(defvar ido-file-history nil 1065(defvar ido-file-history nil
1001 "History of files selected using `ido-find-file'.") 1066 "History of files selected using `ido-find-file'.")
1002 1067
@@ -1027,7 +1092,10 @@ Each element in the list is of the form (DIR (MTIME) FILE...).")
1027Intended to be let-bound by functions which call Ido repeatedly. 1092Intended to be let-bound by functions which call Ido repeatedly.
1028Should never be set permanently.") 1093Should never be set permanently.")
1029 1094
1030;; Temporary storage 1095;;;; Temporary storage
1096
1097(defvar ido-completion-map nil
1098 "Currently active keymap for Ido commands.")
1031 1099
1032(defvar ido-eoinput 1 1100(defvar ido-eoinput 1
1033 "Point where minibuffer input ends and completion info begins. 1101 "Point where minibuffer input ends and completion info begins.
@@ -1086,13 +1154,14 @@ Value is an integer which is number of chars to right of prompt.")
1086This is a copy of `recentf-list', pared down and with faces applied. 1154This is a copy of `recentf-list', pared down and with faces applied.
1087Only used if `ido-use-virtual-buffers' is non-nil.") 1155Only used if `ido-use-virtual-buffers' is non-nil.")
1088 1156
1089;;; Variables with dynamic bindings. 1157;;;; Variables with dynamic bindings.
1090;;; Declared here to keep the byte compiler quiet. 1158
1159;; These are declared here to keep the byte compiler quiet.
1091 1160
1092;; Stores the current ido item type ('file, 'dir, 'buffer, or 'list). 1161;; Stores the current ido item type ('file, 'dir, 'buffer, or 'list).
1093(defvar ido-cur-item) 1162(defvar ido-cur-item)
1094 1163
1095;;; Stores the current default item 1164;; Stores the current default item.
1096(defvar ido-default-item) 1165(defvar ido-default-item)
1097 1166
1098;; Stores the current list of items that will be searched through. 1167;; Stores the current list of items that will be searched through.
@@ -1502,7 +1571,6 @@ Removes badly formatted data and ignored directories."
1502 (ido-save-history)) 1571 (ido-save-history))
1503 1572
1504(defun ido-common-initialization () 1573(defun ido-common-initialization ()
1505 (ido-init-completion-maps)
1506 (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup) 1574 (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup)
1507 (add-hook 'choose-completion-string-functions 'ido-choose-completion-string)) 1575 (add-hook 'choose-completion-string-functions 'ido-choose-completion-string))
1508 1576
@@ -1596,120 +1664,51 @@ This function also adds a hook to the minibuffer."
1596 1664
1597 1665
1598;;; IDO KEYMAP 1666;;; IDO KEYMAP
1599(defun ido-init-completion-maps ()
1600 "Set up the completion keymaps used by Ido."
1601
1602 ;; Common map
1603 (let ((map (make-sparse-keymap)))
1604 (define-key map "\C-a" 'ido-toggle-ignore)
1605 (define-key map "\C-c" 'ido-toggle-case)
1606 (define-key map "\C-e" 'ido-edit-input)
1607 (define-key map "\t" 'ido-complete)
1608 (define-key map " " 'ido-complete-space)
1609 (define-key map "\C-j" 'ido-select-text)
1610 (define-key map "\C-m" 'ido-exit-minibuffer)
1611 (define-key map "\C-p" 'ido-toggle-prefix)
1612 (define-key map "\C-r" 'ido-prev-match)
1613 (define-key map "\C-s" 'ido-next-match)
1614 (define-key map [?\C-.] 'ido-next-match)
1615 (define-key map [?\C-,] 'ido-prev-match)
1616 (define-key map "\C-t" 'ido-toggle-regexp)
1617 (define-key map "\C-z" 'ido-undo-merge-work-directory)
1618 (define-key map [(control ?\s)] 'ido-restrict-to-matches)
1619 (define-key map [(meta ?\s)] 'ido-take-first-match)
1620 (define-key map [(control ?@)] 'ido-restrict-to-matches)
1621 (define-key map [right] 'ido-next-match)
1622 (define-key map [left] 'ido-prev-match)
1623 (define-key map "?" 'ido-completion-help)
1624 ;; Magic commands.
1625 (define-key map "\C-b" 'ido-magic-backward-char)
1626 (define-key map "\C-f" 'ido-magic-forward-char)
1627 (define-key map "\C-d" 'ido-magic-delete-char)
1628 (set-keymap-parent map minibuffer-local-map)
1629 (setq ido-common-completion-map map))
1630
1631 ;; File and directory map
1632 (let ((map (make-sparse-keymap)))
1633 (define-key map "\C-x\C-b" 'ido-enter-switch-buffer)
1634 (define-key map "\C-x\C-f" 'ido-fallback-command)
1635 (define-key map "\C-x\C-d" 'ido-enter-dired)
1636 (define-key map [down] 'ido-next-match-dir)
1637 (define-key map [up] 'ido-prev-match-dir)
1638 (define-key map [(meta up)] 'ido-prev-work-directory)
1639 (define-key map [(meta down)] 'ido-next-work-directory)
1640 (define-key map [backspace] 'ido-delete-backward-updir)
1641 (define-key map "\d" 'ido-delete-backward-updir)
1642 (define-key map [remap delete-backward-char] 'ido-delete-backward-updir) ; BS
1643 (define-key map [remap backward-kill-word] 'ido-delete-backward-word-updir) ; M-DEL
1644 1667
1645 (define-key map [(control backspace)] 'ido-up-directory) 1668(defalias 'ido-init-completion-maps 'ignore "")
1646 (define-key map "\C-l" 'ido-reread-directory) 1669(make-obsolete 'ido-init-completion-maps "it does nothing." "25.1")
1647 (define-key map [(meta ?d)] 'ido-wide-find-dir-or-delete-dir)
1648 (define-key map [(meta ?b)] 'ido-push-dir)
1649 (define-key map [(meta ?v)] 'ido-push-dir-first)
1650 (define-key map [(meta ?f)] 'ido-wide-find-file-or-pop-dir)
1651 (define-key map [(meta ?k)] 'ido-forget-work-directory)
1652 (define-key map [(meta ?m)] 'ido-make-directory)
1653 (define-key map [(meta ?n)] 'ido-next-work-directory)
1654 (define-key map [(meta ?o)] 'ido-prev-work-file)
1655 (define-key map [(meta control ?o)] 'ido-next-work-file)
1656 (define-key map [(meta ?p)] 'ido-prev-work-directory)
1657 (define-key map [(meta ?s)] 'ido-merge-work-directories)
1658 (set-keymap-parent map ido-common-completion-map)
1659 (setq ido-file-dir-completion-map map))
1660 1670
1661 ;; File only map 1671(defun ido-setup-completion-map ()
1662 (let ((map (make-sparse-keymap))) 1672 "Set up the completion keymap used by Ido.
1663 (define-key map "\C-k" 'ido-delete-file-at-head)
1664 (define-key map "\C-o" 'ido-copy-current-word)
1665 (define-key map "\C-w" 'ido-copy-current-file-name)
1666 (define-key map [(meta ?l)] 'ido-toggle-literal)
1667 (set-keymap-parent map ido-file-dir-completion-map)
1668 (setq ido-file-completion-map map))
1669 1673
1670 ;; Buffer map 1674Create a keymap, bind `ido-completion-map' to it, and depending
1671 (let ((map (make-sparse-keymap))) 1675on what is being completed (`ido-cur-item') set its parent keymap
1672 (define-key map "\C-x\C-f" 'ido-enter-find-file) 1676to one of:
1673 (define-key map "\C-x\C-b" 'ido-fallback-command)
1674 (define-key map "\C-k" 'ido-kill-buffer-at-head)
1675 (define-key map [?\C-\S-b] 'ido-bury-buffer-at-head)
1676 (define-key map "\C-o" 'ido-toggle-virtual-buffers)
1677 (set-keymap-parent map ido-common-completion-map)
1678 (setq ido-buffer-completion-map map)))
1679 1677
1678 `ido-common-completion-map'
1679 `ido-file-dir-completion-map'
1680 `ido-file-completion-map'
1681 `ido-buffer-completion-map'
1680 1682
1681(defun ido-setup-completion-map () 1683If option `ido-context-switch-command' is non-nil or `viper-mode'
1682 "Set up the keymap for Ido." 1684is enabled then some keybindings are changed in the keymap."
1683
1684 ;; generated every time so that it can inherit new functions. 1685 ;; generated every time so that it can inherit new functions.
1685 (let ((map (make-sparse-keymap)) 1686 (let ((map (make-sparse-keymap))
1686 (viper-p (if (boundp 'viper-mode) viper-mode))) 1687 (viper-p (if (boundp 'viper-mode) viper-mode)))
1687
1688 (when viper-p 1688 (when viper-p
1689 (define-key map [remap viper-intercept-ESC-key] 'ignore)) 1689 (define-key map [remap viper-intercept-ESC-key] 'ignore))
1690 1690 (pcase ido-cur-item
1691 (cond 1691 ((or `file `dir)
1692 ((memq ido-cur-item '(file dir))
1693 (when ido-context-switch-command 1692 (when ido-context-switch-command
1694 (define-key map "\C-x\C-b" ido-context-switch-command) 1693 (define-key map "\C-x\C-b" ido-context-switch-command)
1695 (define-key map "\C-x\C-d" 'ignore)) 1694 (define-key map "\C-x\C-d" 'ignore))
1696 (when viper-p 1695 (when viper-p
1697 (define-key map [remap viper-backward-char] 'ido-delete-backward-updir) 1696 (define-key map [remap viper-backward-char]
1698 (define-key map [remap viper-del-backward-char-in-insert] 'ido-delete-backward-updir) 1697 'ido-delete-backward-updir)
1699 (define-key map [remap viper-delete-backward-word] 'ido-delete-backward-word-updir)) 1698 (define-key map [remap viper-del-backward-char-in-insert]
1699 'ido-delete-backward-updir)
1700 (define-key map [remap viper-delete-backward-word]
1701 'ido-delete-backward-word-updir))
1700 (set-keymap-parent map 1702 (set-keymap-parent map
1701 (if (eq ido-cur-item 'file) 1703 (if (eq ido-cur-item 'file)
1702 ido-file-completion-map 1704 ido-file-completion-map
1703 ido-file-dir-completion-map))) 1705 ido-file-dir-completion-map)))
1704 1706 (`buffer
1705 ((eq ido-cur-item 'buffer)
1706 (when ido-context-switch-command 1707 (when ido-context-switch-command
1707 (define-key map "\C-x\C-f" ido-context-switch-command)) 1708 (define-key map "\C-x\C-f" ido-context-switch-command))
1708 (set-keymap-parent map ido-buffer-completion-map)) 1709 (set-keymap-parent map ido-buffer-completion-map))
1709 1710 (_
1710 (t
1711 (set-keymap-parent map ido-common-completion-map))) 1711 (set-keymap-parent map ido-common-completion-map)))
1712
1713 (setq ido-completion-map map))) 1712 (setq ido-completion-map map)))
1714 1713
1715(defun ido-final-slash (dir &optional fix-it) 1714(defun ido-final-slash (dir &optional fix-it)
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 7f77d218a48..12123c8f2e2 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -51,6 +51,7 @@
51(require 'cl-lib) 51(require 'cl-lib)
52(require 'eieio) 52(require 'eieio)
53(require 'ring) 53(require 'ring)
54(require 'pcase)
54 55
55(defgroup xref nil "Cross-referencing commands" 56(defgroup xref nil "Cross-referencing commands"
56 :group 'tools) 57 :group 'tools)
@@ -333,19 +334,32 @@ WINDOW controls how the buffer is displayed:
333 334
334;; The xref buffer is used to display a set of xrefs. 335;; The xref buffer is used to display a set of xrefs.
335 336
336(defvar-local xref--window-configuration nil) 337(defvar-local xref--display-history nil
338 "List of pairs (BUFFER . WINDOW), for temporarily displayed buffers.")
337 339
338(defun xref--display-position (pos other-window recenter-arg) 340(defun xref--save-to-history (buf win)
339 ;; show the location, but don't hijack focus. 341 (let ((restore (window-parameter win 'quit-restore)))
342 ;; Save the new entry if the window displayed another buffer
343 ;; previously.
344 (when (and restore (not (eq (car restore) 'same)))
345 (push (cons buf win) xref--display-history))))
346
347(defun xref--display-position (pos other-window recenter-arg xref-buf)
348 ;; Show the location, but don't hijack focus.
340 (with-selected-window (display-buffer (current-buffer) other-window) 349 (with-selected-window (display-buffer (current-buffer) other-window)
341 (goto-char pos) 350 (goto-char pos)
342 (recenter recenter-arg))) 351 (recenter recenter-arg)
352 (let ((buf (current-buffer))
353 (win (selected-window)))
354 (with-current-buffer xref-buf
355 (setq-local other-window-scroll-buffer buf)
356 (xref--save-to-history buf win)))))
343 357
344(defun xref--show-location (location) 358(defun xref--show-location (location)
345 (condition-case err 359 (condition-case err
346 (progn 360 (let ((xref-buf (current-buffer)))
347 (xref--goto-location location) 361 (xref--goto-location location)
348 (xref--display-position (point) t 1)) 362 (xref--display-position (point) t 1 xref-buf))
349 (user-error (message (error-message-string err))))) 363 (user-error (message (error-message-string err)))))
350 364
351(defun xref-show-location-at-point () 365(defun xref-show-location-at-point ()
@@ -353,14 +367,8 @@ WINDOW controls how the buffer is displayed:
353 (interactive) 367 (interactive)
354 (let ((loc (xref--location-at-point))) 368 (let ((loc (xref--location-at-point)))
355 (when loc 369 (when loc
356 (setq xref--window-configuration (current-window-configuration))
357 (xref--show-location loc)))) 370 (xref--show-location loc))))
358 371
359(defun xref--restore-window-configuration ()
360 (when xref--window-configuration
361 (set-window-configuration xref--window-configuration)
362 (setq xref--window-configuration nil)))
363
364(defun xref-next-line () 372(defun xref-next-line ()
365 "Move to the next xref and display its source in the other window." 373 "Move to the next xref and display its source in the other window."
366 (interactive) 374 (interactive)
@@ -379,21 +387,21 @@ WINDOW controls how the buffer is displayed:
379(defvar-local xref--window nil) 387(defvar-local xref--window nil)
380 388
381(defun xref-goto-xref () 389(defun xref-goto-xref ()
382 "Jump to the xref at point and bury the xref buffer." 390 "Jump to the xref on the current line and bury the xref buffer."
383 (interactive) 391 (interactive)
392 (back-to-indentation)
384 (let ((loc (or (xref--location-at-point) 393 (let ((loc (or (xref--location-at-point)
385 (error "No reference at point"))) 394 (user-error "No reference at point")))
386 (window xref--window)) 395 (window xref--window))
387 (quit-window) 396 (xref--quit)
388 (xref--pop-to-location loc window))) 397 (xref--pop-to-location loc window)))
389 398
390(define-derived-mode xref--xref-buffer-mode fundamental-mode "XREF" 399(define-derived-mode xref--xref-buffer-mode fundamental-mode "XREF"
391 "Mode for displaying cross-references." 400 "Mode for displaying cross-references."
392 (setq buffer-read-only t) 401 (setq buffer-read-only t))
393 (add-hook 'pre-command-hook #'xref--restore-window-configuration nil t))
394 402
395(let ((map xref--xref-buffer-mode-map)) 403(let ((map xref--xref-buffer-mode-map))
396 (define-key map (kbd "q") #'quit-window) 404 (define-key map (kbd "q") #'xref--quit)
397 (define-key map (kbd "n") #'xref-next-line) 405 (define-key map (kbd "n") #'xref-next-line)
398 (define-key map (kbd "p") #'xref-prev-line) 406 (define-key map (kbd "p") #'xref-prev-line)
399 (define-key map (kbd "RET") #'xref-goto-xref) 407 (define-key map (kbd "RET") #'xref-goto-xref)
@@ -403,6 +411,18 @@ WINDOW controls how the buffer is displayed:
403 (define-key map (kbd ".") #'xref-next-line) 411 (define-key map (kbd ".") #'xref-next-line)
404 (define-key map (kbd ",") #'xref-prev-line)) 412 (define-key map (kbd ",") #'xref-prev-line))
405 413
414(defun xref--quit ()
415 "Quit all windows in `xref--display-history', then quit current window."
416 (interactive)
417 (let ((window (selected-window))
418 (history xref--display-history))
419 (setq xref--display-history nil)
420 (pcase-dolist (`(,buf . ,win) history)
421 (when (and (window-live-p win)
422 (eq buf (window-buffer win)))
423 (quit-window nil win)))
424 (quit-window nil window)))
425
406(defconst xref-buffer-name "*xref*" 426(defconst xref-buffer-name "*xref*"
407 "The name of the buffer to show xrefs.") 427 "The name of the buffer to show xrefs.")
408 428