aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorKenichi Handa2013-09-08 21:17:12 +0900
committerKenichi Handa2013-09-08 21:17:12 +0900
commit3aff2f57cc348b90c0f8b5926027cd0f0f378070 (patch)
treeff714b2645779c262a714ed7ae1d97a155d21438 /lisp
parent0ca754d0d8df545ce4c09d65a337f67213e2f82b (diff)
parente8dd0787d9c19e81344552d185e9008031f58723 (diff)
downloademacs-3aff2f57cc348b90c0f8b5926027cd0f0f378070.tar.gz
emacs-3aff2f57cc348b90c0f8b5926027cd0f0f378070.zip
merge trunk
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog139
-rw-r--r--lisp/abbrev.el19
-rw-r--r--lisp/arc-mode.el23
-rw-r--r--lisp/dired-x.el32
-rw-r--r--lisp/dired.el2
-rw-r--r--lisp/emacs-lisp/crm.el62
-rw-r--r--lisp/epa.el71
-rw-r--r--lisp/epg.el5
-rw-r--r--lisp/icomplete.el24
-rw-r--r--lisp/info.el11
-rw-r--r--lisp/minibuffer.el225
-rw-r--r--lisp/net/tramp-gvfs.el6
-rw-r--r--lisp/net/tramp.el107
-rw-r--r--lisp/progmodes/cc-engine.el54
-rw-r--r--lisp/progmodes/cc-langs.el5
-rw-r--r--lisp/progmodes/ruby-mode.el4
-rw-r--r--lisp/replace.el9
-rw-r--r--lisp/textmodes/bibtex.el2
18 files changed, 453 insertions, 347 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 30d00750926..e919a8407ec 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -3,6 +3,121 @@
3 * international/characters.el: Set category "^" (Combining) for 3 * international/characters.el: Set category "^" (Combining) for
4 more characters. 4 more characters.
5 5
62013-09-07 Alan Mackenzie <acm@muc.de>
7
8 Correctly fontify Java class constructors.
9 * progmodes/cc-langs.el (c-type-decl-suffix-key): Now matches ")"
10 in Java Mode.
11 (c-recognize-typeless-decls): Set the Java value to t.
12 * progmodes/cc-engine.el (c-forward-decl-or-cast-1): While
13 handling a "(", add a check for, effectively, Java, and handle a
14 "typeless" declaration there.
15
162013-09-07 Roland Winkler <winkler@gnu.org>
17
18 * textmodes/bibtex.el (bibtex-biblatex-entry-alist): Add optional
19 field subtitle for entry type book.
20
212013-09-06 Stefan Monnier <monnier@iro.umontreal.ca>
22
23 * minibuffer.el: Make minibuffer-complete call completion-in-region
24 rather than other way around.
25 (completion--some, completion-pcm--find-all-completions):
26 Don't delay signals when debugging.
27 (minibuffer-completion-contents): Beware fields within the
28 minibuffer contents.
29 (completion-all-sorted-completions): Use defvar-local.
30 (completion--do-completion, completion--cache-all-sorted-completions)
31 (completion-all-sorted-completions, minibuffer-force-complete):
32 Add args `beg' and `end'.
33 (completion--in-region-1): New fun, extracted from minibuffer-complete.
34 (minibuffer-complete): Use completion-in-region.
35 (completion-complete-and-exit): New fun, extracted from
36 minibuffer-complete-and-exit.
37 (minibuffer-complete-and-exit): Use it.
38 (completion--complete-and-exit): Rename from
39 minibuffer--complete-and-exit.
40 (completion-in-region--single-word): New function, extracted from
41 minibuffer-complete-word.
42 (minibuffer-complete-word): Use it.
43 (display-completion-list): Make `common-substring' argument obsolete.
44 (completion--in-region): Call completion--in-region-1 instead of
45 minibuffer-complete.
46 (completion-help-at-point): Pass boundaries to
47 minibuffer-completion-help as args rather than via an overlay.
48 (completion-pcm--string->pattern): Use `any-delim'.
49 (completion-pcm--optimize-pattern): New function.
50 (completion-pcm--pattern->regex): Handle `any-delim'.
51 * icomplete.el (icomplete-forward-completions)
52 (icomplete-backward-completions, icomplete-completions):
53 Adjust calls to completion-all-sorted-completions and
54 completion--cache-all-sorted-completions.
55 (icomplete-with-completion-tables): Default to t.
56 * emacs-lisp/crm.el (crm--current-element): Rename from
57 crm--select-current-element. Don't put an overlay but return the
58 boundaries instead.
59 (crm--completion-command): Take two new args to bind to the boundaries.
60 (crm-completion-help): Adjust accordingly.
61 (crm-complete): Use completion-in-region.
62 (crm-complete-word): Use completion-in-region--single-word.
63 (crm-complete-and-exit): Use completion-complete-and-exit.
64
652013-09-06 Stefan Monnier <monnier@iro.umontreal.ca>
66
67 * dired-x.el (dired-mark-sexp): Bind the vars lexically rather
68 than dynamically.
69
702013-09-06 Juri Linkov <juri@jurta.org>
71
72 * info.el (Info-display-images-node): When image file doesn't exist
73 display text version of the image if it's provided in the Info file.
74 Otherwise, display the location of missing image from SRC attribute.
75 Add help-echo text property from ALT attribute. (Bug#15279)
76
772013-09-06 Stefan Monnier <monnier@iro.umontreal.ca>
78
79 * abbrev.el (edit-abbrevs-mode-map): Rename from edit-abbrevs-map.
80 (edit-abbrevs-mode): Use define-derived-mode.
81
82 * epa.el (epa--encode-coding-string, epa--decode-coding-string)
83 (epa--select-safe-coding-system, epa--derived-mode-p): Make it obvious
84 that it's defined.
85 (epa-key-list-mode, epa-key-mode, epa-info-mode):
86 Use define-derived-mode.
87
88 * epg.el (epg-start-encrypt): Minor CSE simplification.
89
902013-09-06 William Xu <william.xwl@gmail.com>
91
92 * arc-mode.el: Add support for 7za (bug#15264).
93 (archive-7z-program): New var.
94 (archive-zip-extract, archive-zip-expunge, archive-zip-update)
95 (archive-zip-update-case, archive-7z-extract, archive-7z-expunge)
96 (archive-7z-update, archive-zip-extract, archive-7z-summarize): Use it.
97
982013-09-06 Michael Albinus <michael.albinus@gmx.de>
99
100 Remove URL syntax.
101
102 * net/tramp.el (tramp-syntax, tramp-prefix-format)
103 (tramp-postfix-method-format, tramp-prefix-ipv6-format)
104 (tramp-postfix-ipv6-format, tramp-prefix-port-format)
105 (tramp-postfix-host-format, tramp-file-name-regexp)
106 (tramp-completion-file-name-regexp)
107 (tramp-completion-dissect-file-name)
108 (tramp-handle-substitute-in-file-name): Remove 'url case.
109 (tramp-file-name-regexp-url)
110 (tramp-completion-file-name-regexp-url): Remove constants.
111
1122013-09-06 Glenn Morris <rgm@gnu.org>
113
114 * replace.el (replace-string): Doc fix re start/end. (Bug#15275)
115
1162013-09-05 Dmitry Gutov <dgutov@yandex.ru>
117
118 * progmodes/ruby-mode.el (ruby-font-lock-keywords): Move "Perl-ish
119 keywords" below "here-doc beginnings" (Bug#15270).
120
62013-09-05 Stefan Monnier <monnier@iro.umontreal.ca> 1212013-09-05 Stefan Monnier <monnier@iro.umontreal.ca>
7 122
8 * subr.el (pop): Use `car-safe'. 123 * subr.el (pop): Use `car-safe'.
@@ -64,6 +179,30 @@
64 179
652013-09-04 Stefan Monnier <monnier@iro.umontreal.ca> 1802013-09-04 Stefan Monnier <monnier@iro.umontreal.ca>
66 181
182 * vc/vc-dispatcher.el (vc-run-delayed): New macro.
183 (vc-do-command, vc-set-async-update):
184 * vc/vc-mtn.el (vc-mtn-dir-status):
185 * vc/vc-hg.el (vc-hg-dir-status, vc-hg-dir-status-files)
186 (vc-hg-pull, vc-hg-merge-branch):
187 * vc/vc-git.el (vc-git-dir-status-goto-stage, vc-git-pull)
188 (vc-git-merge-branch):
189 * vc/vc-cvs.el (vc-cvs-print-log, vc-cvs-dir-status)
190 (vc-cvs-dir-status-files):
191 * vc/vc-bzr.el (vc-bzr-pull, vc-bzr-merge-branch, vc-bzr-dir-status)
192 (vc-bzr-dir-status-files):
193 * vc/vc-arch.el (vc-arch-dir-status): Use vc-run-delayed.
194 * vc/vc-annotate.el: Use lexical-binding.
195 (vc-annotate-display-select, vc-annotate): Use vc-run-delayed.
196 (vc-sentinel-movepoint): Declare.
197 (vc-annotate): Don't use `goto-line'.
198 * vc/vc.el (vc-diff-internal): Prefer a closure to `(lambda...).
199 (vc-diff-internal, vc-log-internal-common): Use vc-run-delayed.
200 (vc-sentinel-movepoint): Declare.
201 * vc/vc-svn.el: Use lexical-binding.
202 (vc-svn-dir-status, vc-svn-dir-status-files): Use vc-run-delayed.
203 * vc/vc-sccs.el:
204 * vc/vc-rcs.el: Use lexical-binding.
205
67 * autorevert.el (auto-revert-notify-handler): Explicitly ignore 206 * autorevert.el (auto-revert-notify-handler): Explicitly ignore
68 `deleted'. Don't drop errors silently. 207 `deleted'. Don't drop errors silently.
69 208
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index d82e2eabd84..d7d4482693d 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -67,13 +67,15 @@ be replaced by its expansion."
67(put 'abbrev-mode 'safe-local-variable 'booleanp) 67(put 'abbrev-mode 'safe-local-variable 'booleanp)
68 68
69 69
70(defvar edit-abbrevs-map 70(defvar edit-abbrevs-mode-map
71 (let ((map (make-sparse-keymap))) 71 (let ((map (make-sparse-keymap)))
72 (define-key map "\C-x\C-s" 'abbrev-edit-save-buffer) 72 (define-key map "\C-x\C-s" 'abbrev-edit-save-buffer)
73 (define-key map "\C-x\C-w" 'abbrev-edit-save-to-file) 73 (define-key map "\C-x\C-w" 'abbrev-edit-save-to-file)
74 (define-key map "\C-c\C-c" 'edit-abbrevs-redefine) 74 (define-key map "\C-c\C-c" 'edit-abbrevs-redefine)
75 map) 75 map)
76 "Keymap used in `edit-abbrevs'.") 76 "Keymap used in `edit-abbrevs'.")
77(define-obsolete-variable-alias 'edit-abbrevs-map
78 'edit-abbrevs-mode-map "24.4")
77 79
78(defun kill-all-abbrevs () 80(defun kill-all-abbrevs ()
79 "Undefine all defined abbrevs." 81 "Undefine all defined abbrevs."
@@ -144,16 +146,6 @@ Otherwise display all abbrevs."
144 (set-buffer-modified-p nil) 146 (set-buffer-modified-p nil)
145 (current-buffer)))) 147 (current-buffer))))
146 148
147(defun edit-abbrevs-mode ()
148 "Major mode for editing the list of abbrev definitions.
149\\{edit-abbrevs-map}"
150 (interactive)
151 (kill-all-local-variables)
152 (setq major-mode 'edit-abbrevs-mode)
153 (setq mode-name "Edit-Abbrevs")
154 (use-local-map edit-abbrevs-map)
155 (run-mode-hooks 'edit-abbrevs-mode-hook))
156
157(defun edit-abbrevs () 149(defun edit-abbrevs ()
158 "Alter abbrev definitions by editing a list of them. 150 "Alter abbrev definitions by editing a list of them.
159Selects a buffer containing a list of abbrev definitions with 151Selects a buffer containing a list of abbrev definitions with
@@ -1013,6 +1005,11 @@ SORTFUN is passed to `sort' to change the default ordering."
1013 (sort entries (lambda (x y) 1005 (sort entries (lambda (x y)
1014 (funcall sortfun (nth 2 x) (nth 2 y))))))) 1006 (funcall sortfun (nth 2 x) (nth 2 y)))))))
1015 1007
1008;; Keep it after define-abbrev-table, since define-derived-mode uses
1009;; define-abbrev-table.
1010(define-derived-mode edit-abbrevs-mode special-mode "Edit-Abbrevs"
1011 "Major mode for editing the list of abbrev definitions.")
1012
1016(provide 'abbrev) 1013(provide 'abbrev)
1017 1014
1018;;; abbrev.el ends here 1015;;; abbrev.el ends here
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 5f001ad977b..a4f7015c844 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -218,9 +218,14 @@ Archive and member name will be added."
218;; ------------------------------ 218;; ------------------------------
219;; Zip archive configuration 219;; Zip archive configuration
220 220
221(defvar archive-7z-program (let ((7z (or (executable-find "7z")
222 (executable-find "7za"))))
223 (when 7z
224 (file-name-nondirectory 7z))))
225
221(defcustom archive-zip-extract 226(defcustom archive-zip-extract
222 (cond ((executable-find "unzip") '("unzip" "-qq" "-c")) 227 (cond ((executable-find "unzip") '("unzip" "-qq" "-c"))
223 ((executable-find "7z") '("7z" "x" "-so")) 228 (archive-7z-program `(,archive-7z-program "x" "-so"))
224 ((executable-find "pkunzip") '("pkunzip" "-e" "-o-")) 229 ((executable-find "pkunzip") '("pkunzip" "-e" "-o-"))
225 (t '("unzip" "-qq" "-c"))) 230 (t '("unzip" "-qq" "-c")))
226 "Program and its options to run in order to extract a zip file member. 231 "Program and its options to run in order to extract a zip file member.
@@ -239,7 +244,7 @@ be added."
239 244
240(defcustom archive-zip-expunge 245(defcustom archive-zip-expunge
241 (cond ((executable-find "zip") '("zip" "-d" "-q")) 246 (cond ((executable-find "zip") '("zip" "-d" "-q"))
242 ((executable-find "7z") '("7z" "d")) 247 (archive-7z-program `(,archive-7z-program "d"))
243 ((executable-find "pkzip") '("pkzip" "-d")) 248 ((executable-find "pkzip") '("pkzip" "-d"))
244 (t '("zip" "-d" "-q"))) 249 (t '("zip" "-d" "-q")))
245 "Program and its options to run in order to delete zip file members. 250 "Program and its options to run in order to delete zip file members.
@@ -252,7 +257,7 @@ Archive and member names will be added."
252 257
253(defcustom archive-zip-update 258(defcustom archive-zip-update
254 (cond ((executable-find "zip") '("zip" "-q")) 259 (cond ((executable-find "zip") '("zip" "-q"))
255 ((executable-find "7z") '("7z" "u")) 260 (archive-7z-program `(,archive-7z-program "u"))
256 ((executable-find "pkzip") '("pkzip" "-u" "-P")) 261 ((executable-find "pkzip") '("pkzip" "-u" "-P"))
257 (t '("zip" "-q"))) 262 (t '("zip" "-q")))
258 "Program and its options to run in order to update a zip file member. 263 "Program and its options to run in order to update a zip file member.
@@ -266,7 +271,7 @@ file. Archive and member name will be added."
266 271
267(defcustom archive-zip-update-case 272(defcustom archive-zip-update-case
268 (cond ((executable-find "zip") '("zip" "-q" "-k")) 273 (cond ((executable-find "zip") '("zip" "-q" "-k"))
269 ((executable-find "7z") '("7z" "u")) 274 (archive-7z-program `(,archive-7z-program "u"))
270 ((executable-find "pkzip") '("pkzip" "-u" "-P")) 275 ((executable-find "pkzip") '("pkzip" "-u" "-P"))
271 (t '("zip" "-q" "-k"))) 276 (t '("zip" "-q" "-k")))
272 "Program and its options to run in order to update a case fiddled zip member. 277 "Program and its options to run in order to update a case fiddled zip member.
@@ -321,7 +326,7 @@ Archive and member name will be added."
321;; 7z archive configuration 326;; 7z archive configuration
322 327
323(defcustom archive-7z-extract 328(defcustom archive-7z-extract
324 '("7z" "x" "-so") 329 `(,archive-7z-program "x" "-so")
325 "Program and its options to run in order to extract a 7z file member. 330 "Program and its options to run in order to extract a 7z file member.
326Extraction should happen to standard output. Archive and member name will 331Extraction should happen to standard output. Archive and member name will
327be added." 332be added."
@@ -333,7 +338,7 @@ be added."
333 :group 'archive-7z) 338 :group 'archive-7z)
334 339
335(defcustom archive-7z-expunge 340(defcustom archive-7z-expunge
336 '("7z" "d") 341 `(,archive-7z-program "d")
337 "Program and its options to run in order to delete 7z file members. 342 "Program and its options to run in order to delete 7z file members.
338Archive and member names will be added." 343Archive and member names will be added."
339 :version "24.1" 344 :version "24.1"
@@ -344,7 +349,7 @@ Archive and member names will be added."
344 :group 'archive-7z) 349 :group 'archive-7z)
345 350
346(defcustom archive-7z-update 351(defcustom archive-7z-update
347 '("7z" "u") 352 `(,archive-7z-program "u")
348 "Program and its options to run in order to update a 7z file member. 353 "Program and its options to run in order to update a 7z file member.
349Options should ensure that specified directory will be put into the 7z 354Options should ensure that specified directory will be put into the 7z
350file. Archive and member name will be added." 355file. Archive and member name will be added."
@@ -1864,7 +1869,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
1864 (cond 1869 (cond
1865 ((member-ignore-case (car archive-zip-extract) '("pkunzip" "pkzip")) 1870 ((member-ignore-case (car archive-zip-extract) '("pkunzip" "pkzip"))
1866 (archive-*-extract archive name archive-zip-extract)) 1871 (archive-*-extract archive name archive-zip-extract))
1867 ((equal (car archive-zip-extract) "7z") 1872 ((equal (car archive-zip-extract) archive-7z-program)
1868 (let ((archive-7z-extract archive-zip-extract)) 1873 (let ((archive-7z-extract archive-zip-extract))
1869 (archive-7z-extract archive name))) 1874 (archive-7z-extract archive name)))
1870 (t 1875 (t
@@ -2088,7 +2093,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
2088 (file buffer-file-name) 2093 (file buffer-file-name)
2089 (files ())) 2094 (files ()))
2090 (with-temp-buffer 2095 (with-temp-buffer
2091 (call-process "7z" nil t nil "l" "-slt" file) 2096 (call-process archive-7z-program nil t nil "l" "-slt" file)
2092 (goto-char (point-min)) 2097 (goto-char (point-min))
2093 ;; Four dashes start the meta info section that should be skipped. 2098 ;; Four dashes start the meta info section that should be skipped.
2094 ;; Archive members start with more than four dashes. 2099 ;; Archive members start with more than four dashes.
diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 3527a3fc756..c6ecbf1e718 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -1,4 +1,4 @@
1;;; dired-x.el --- extra Dired functionality 1;;; dired-x.el --- extra Dired functionality -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 1993-1994, 1997, 2001-2013 Free Software Foundation, 3;; Copyright (C) 1993-1994, 1997, 2001-2013 Free Software Foundation,
4;; Inc. 4;; Inc.
@@ -1185,7 +1185,7 @@ results in
1185 (setq count (1+ count) 1185 (setq count (1+ count)
1186 start (1+ start))) 1186 start (1+ start)))
1187 ;; ... and prepend a "../" for each slash found: 1187 ;; ... and prepend a "../" for each slash found:
1188 (dotimes (n count) 1188 (dotimes (_ count)
1189 (setq name1 (concat "../" name1))))) 1189 (setq name1 (concat "../" name1)))))
1190 (make-symbolic-link 1190 (make-symbolic-link
1191 (directory-file-name name1) ; must not link to foo/ 1191 (directory-file-name name1) ; must not link to foo/
@@ -1397,22 +1397,6 @@ Considers buffers closer to the car of `buffer-list' to be more recent."
1397;; Does anyone use this? - lrd 6/29/93. 1397;; Does anyone use this? - lrd 6/29/93.
1398;; Apparently people do use it. - lrd 12/22/97. 1398;; Apparently people do use it. - lrd 12/22/97.
1399 1399
1400(with-no-warnings
1401 ;; Warnings are suppressed to avoid "global/dynamic var `X' lacks a prefix".
1402 ;; This is unbearably ugly, but not more than having global variables
1403 ;; named size, time, name or s, however practical it can be while writing
1404 ;; `dired-mark-sexp' predicates.
1405 (defvar inode)
1406 (defvar s)
1407 (defvar mode)
1408 (defvar nlink)
1409 (defvar uid)
1410 (defvar gid)
1411 (defvar size)
1412 (defvar time)
1413 (defvar name)
1414 (defvar sym))
1415
1416(defun dired-mark-sexp (predicate &optional unflag-p) 1400(defun dired-mark-sexp (predicate &optional unflag-p)
1417 "Mark files for which PREDICATE returns non-nil. 1401 "Mark files for which PREDICATE returns non-nil.
1418With a prefix arg, unmark or unflag those files instead. 1402With a prefix arg, unmark or unflag those files instead.
@@ -1505,7 +1489,17 @@ to mark all zero length files."
1505 (line-end-position)) 1489 (line-end-position))
1506 "")) 1490 ""))
1507 t) 1491 t)
1508 (eval predicate))) 1492 (eval predicate
1493 `((inode . ,inode)
1494 (s . ,s)
1495 (mode . ,mode)
1496 (nlink . ,nlink)
1497 (uid . ,uid)
1498 (gid . ,gid)
1499 (size . ,size)
1500 (time . ,time)
1501 (name . ,name)
1502 (sym . ,sym)))))
1509 (format "'%s file" predicate)))) 1503 (format "'%s file" predicate))))
1510 1504
1511 1505
diff --git a/lisp/dired.el b/lisp/dired.el
index b9f974234fb..f873aea9bf0 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -4352,7 +4352,7 @@ instead.
4352 4352
4353;;;*** 4353;;;***
4354 4354
4355;;;### (autoloads nil "dired-x" "dired-x.el" "130484d4c94bb9929c210774f9e475f5") 4355;;;### (autoloads nil "dired-x" "dired-x.el" "1bf4009b81e55bf51947bc87b2c82994")
4356;;; Generated autoloads from dired-x.el 4356;;; Generated autoloads from dired-x.el
4357 4357
4358(autoload 'dired-jump "dired-x" "\ 4358(autoload 'dired-jump "dired-x" "\
diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el
index b8e327625e7..750e0709591 100644
--- a/lisp/emacs-lisp/crm.el
+++ b/lisp/emacs-lisp/crm.el
@@ -157,33 +157,32 @@ Functions'."
157 predicate 157 predicate
158 flag))) 158 flag)))
159 159
160(defun crm--select-current-element () 160(defun crm--current-element ()
161 "Parse the minibuffer to find the current element. 161 "Parse the minibuffer to find the current element.
162Place an overlay on the element, with a `field' property, and return it." 162Return the element's boundaries as (START . END)."
163 (let* ((bob (minibuffer-prompt-end)) 163 (let ((bob (minibuffer-prompt-end)))
164 (start (save-excursion 164 (cons (save-excursion
165 (if (re-search-backward crm-separator bob t) 165 (if (re-search-backward crm-separator bob t)
166 (match-end 0) 166 (match-end 0)
167 bob))) 167 bob))
168 (end (save-excursion 168 (save-excursion
169 (if (re-search-forward crm-separator nil t) 169 (if (re-search-forward crm-separator nil t)
170 (match-beginning 0) 170 (match-beginning 0)
171 (point-max)))) 171 (point-max))))))
172 (ol (make-overlay start end nil nil t))) 172
173 (overlay-put ol 'field (make-symbol "crm")) 173(defmacro crm--completion-command (beg end &rest body)
174 ol)) 174 "Run BODY with BEG and END bound to the current element's boundaries."
175 175 (declare (indent 2) (debug (sexp sexp &rest body)))
176(defmacro crm--completion-command (command) 176 `(let* ((crm--boundaries (crm--current-element))
177 "Make COMMAND a completion command for `completing-read-multiple'." 177 (,beg (car crm--boundaries))
178 `(let ((ol (crm--select-current-element))) 178 (,end (cdr crm--boundaries)))
179 (unwind-protect 179 ,@body))
180 ,command
181 (delete-overlay ol))))
182 180
183(defun crm-completion-help () 181(defun crm-completion-help ()
184 "Display a list of possible completions of the current minibuffer element." 182 "Display a list of possible completions of the current minibuffer element."
185 (interactive) 183 (interactive)
186 (crm--completion-command (minibuffer-completion-help)) 184 (crm--completion-command beg end
185 (minibuffer-completion-help beg end))
187 nil) 186 nil)
188 187
189(defun crm-complete () 188(defun crm-complete ()
@@ -192,13 +191,18 @@ If no characters can be completed, display a list of possible completions.
192 191
193Return t if the current element is now a valid match; otherwise return nil." 192Return t if the current element is now a valid match; otherwise return nil."
194 (interactive) 193 (interactive)
195 (crm--completion-command (minibuffer-complete))) 194 (crm--completion-command beg end
195 (completion-in-region beg end
196 minibuffer-completion-table
197 minibuffer-completion-predicate)))
196 198
197(defun crm-complete-word () 199(defun crm-complete-word ()
198 "Complete the current element at most a single word. 200 "Complete the current element at most a single word.
199Like `minibuffer-complete-word' but for `completing-read-multiple'." 201Like `minibuffer-complete-word' but for `completing-read-multiple'."
200 (interactive) 202 (interactive)
201 (crm--completion-command (minibuffer-complete-word))) 203 (crm--completion-command beg end
204 (completion-in-region--single-word
205 beg end minibuffer-completion-table minibuffer-completion-predicate)))
202 206
203(defun crm-complete-and-exit () 207(defun crm-complete-and-exit ()
204 "If all of the minibuffer elements are valid completions then exit. 208 "If all of the minibuffer elements are valid completions then exit.
@@ -211,16 +215,14 @@ This function is modeled after `minibuffer-complete-and-exit'."
211 (goto-char (minibuffer-prompt-end)) 215 (goto-char (minibuffer-prompt-end))
212 (while 216 (while
213 (and doexit 217 (and doexit
214 (let ((ol (crm--select-current-element))) 218 (crm--completion-command beg end
215 (goto-char (overlay-end ol)) 219 (let ((end (copy-marker end t)))
216 (unwind-protect 220 (goto-char end)
217 (catch 'exit 221 (setq doexit nil)
218 (minibuffer-complete-and-exit) 222 (completion-complete-and-exit beg end
219 ;; This did not throw `exit', so there was a problem. 223 (lambda () (setq doexit t)))
220 (setq doexit nil)) 224 (goto-char end)
221 (goto-char (overlay-end ol)) 225 (not (eobp))))
222 (delete-overlay ol))
223 (not (eobp)))
224 (looking-at crm-separator)) 226 (looking-at crm-separator))
225 ;; Skip to the next element. 227 ;; Skip to the next element.
226 (goto-char (match-end 0))) 228 (goto-char (match-end 0)))
diff --git a/lisp/epa.el b/lisp/epa.el
index a99fb9230e1..1b06e6ca3bf 100644
--- a/lisp/epa.el
+++ b/lisp/epa.el
@@ -268,62 +268,40 @@ You should bind this variable with `let', but do not set it globally.")
268 (epg-sub-key-id (car (epg-key-sub-key-list 268 (epg-sub-key-id (car (epg-key-sub-key-list
269 (widget-get widget :value)))))) 269 (widget-get widget :value))))))
270 270
271(eval-and-compile 271(defalias 'epa--encode-coding-string
272 (if (fboundp 'encode-coding-string) 272 (if (fboundp 'encode-coding-string) #'encode-coding-string #'identity))
273 (defalias 'epa--encode-coding-string 'encode-coding-string)
274 (defalias 'epa--encode-coding-string 'identity)))
275 273
276(eval-and-compile 274(defalias 'epa--decode-coding-string
277 (if (fboundp 'decode-coding-string) 275 (if (fboundp 'decode-coding-string) #'decode-coding-string #'identity))
278 (defalias 'epa--decode-coding-string 'decode-coding-string)
279 (defalias 'epa--decode-coding-string 'identity)))
280 276
281(defun epa-key-list-mode () 277(define-derived-mode epa-key-list-mode special-mode "Keys"
282 "Major mode for `epa-list-keys'." 278 "Major mode for `epa-list-keys'."
283 (kill-all-local-variables)
284 (buffer-disable-undo) 279 (buffer-disable-undo)
285 (setq major-mode 'epa-key-list-mode 280 (setq truncate-lines t
286 mode-name "Keys"
287 truncate-lines t
288 buffer-read-only t) 281 buffer-read-only t)
289 (use-local-map epa-key-list-mode-map) 282 (setq-local font-lock-defaults '(epa-font-lock-keywords t))
290 (make-local-variable 'font-lock-defaults)
291 (setq font-lock-defaults '(epa-font-lock-keywords t))
292 ;; In XEmacs, auto-initialization of font-lock is not effective 283 ;; In XEmacs, auto-initialization of font-lock is not effective
293 ;; if buffer-file-name is not set. 284 ;; if buffer-file-name is not set.
294 (font-lock-set-defaults) 285 (font-lock-set-defaults)
295 (make-local-variable 'epa-exit-buffer-function) 286 (make-local-variable 'epa-exit-buffer-function)
296 (make-local-variable 'revert-buffer-function) 287 (setq-local revert-buffer-function #'epa--key-list-revert-buffer))
297 (setq revert-buffer-function 'epa--key-list-revert-buffer)
298 (run-mode-hooks 'epa-key-list-mode-hook))
299 288
300(defun epa-key-mode () 289(define-derived-mode epa-key-mode special-mode "Key"
301 "Major mode for a key description." 290 "Major mode for a key description."
302 (kill-all-local-variables)
303 (buffer-disable-undo) 291 (buffer-disable-undo)
304 (setq major-mode 'epa-key-mode 292 (setq truncate-lines t
305 mode-name "Key"
306 truncate-lines t
307 buffer-read-only t) 293 buffer-read-only t)
308 (use-local-map epa-key-mode-map) 294 (setq-local font-lock-defaults '(epa-font-lock-keywords t))
309 (make-local-variable 'font-lock-defaults)
310 (setq font-lock-defaults '(epa-font-lock-keywords t))
311 ;; In XEmacs, auto-initialization of font-lock is not effective 295 ;; In XEmacs, auto-initialization of font-lock is not effective
312 ;; if buffer-file-name is not set. 296 ;; if buffer-file-name is not set.
313 (font-lock-set-defaults) 297 (font-lock-set-defaults)
314 (make-local-variable 'epa-exit-buffer-function) 298 (make-local-variable 'epa-exit-buffer-function))
315 (run-mode-hooks 'epa-key-mode-hook))
316 299
317(defun epa-info-mode () 300(define-derived-mode epa-info-mode special-mode "Info"
318 "Major mode for `epa-info-buffer'." 301 "Major mode for `epa-info-buffer'."
319 (kill-all-local-variables)
320 (buffer-disable-undo) 302 (buffer-disable-undo)
321 (setq major-mode 'epa-info-mode 303 (setq truncate-lines t
322 mode-name "Info" 304 buffer-read-only t))
323 truncate-lines t
324 buffer-read-only t)
325 (use-local-map epa-info-mode-map)
326 (run-mode-hooks 'epa-info-mode-hook))
327 305
328(defun epa-mark-key (&optional arg) 306(defun epa-mark-key (&optional arg)
329 "Mark a key on the current line. 307 "Mark a key on the current line.
@@ -951,10 +929,10 @@ See the reason described in the `epa-verify-region' documentation."
951 (error "No cleartext tail")) 929 (error "No cleartext tail"))
952 (epa-verify-region cleartext-start cleartext-end)))))) 930 (epa-verify-region cleartext-start cleartext-end))))))
953 931
954(eval-and-compile 932(defalias 'epa--select-safe-coding-system
955 (if (fboundp 'select-safe-coding-system) 933 (if (fboundp 'select-safe-coding-system)
956 (defalias 'epa--select-safe-coding-system 'select-safe-coding-system) 934 #'select-safe-coding-system
957 (defun epa--select-safe-coding-system (_from _to) 935 (lambda (_from _to)
958 buffer-file-coding-system))) 936 buffer-file-coding-system)))
959 937
960;;;###autoload 938;;;###autoload
@@ -1026,16 +1004,16 @@ If no one is selected, default secret key is used. "
1026 'start-open t 1004 'start-open t
1027 'end-open t))))) 1005 'end-open t)))))
1028 1006
1029(eval-and-compile 1007(defalias 'epa--derived-mode-p
1030 (if (fboundp 'derived-mode-p) 1008 (if (fboundp 'derived-mode-p)
1031 (defalias 'epa--derived-mode-p 'derived-mode-p) 1009 #'derived-mode-p
1032 (defun epa--derived-mode-p (&rest modes) 1010 (lambda (&rest modes)
1033 "Non-nil if the current major mode is derived from one of MODES. 1011 "Non-nil if the current major mode is derived from one of MODES.
1034Uses the `derived-mode-parent' property of the symbol to trace backwards." 1012Uses the `derived-mode-parent' property of the symbol to trace backwards."
1035 (let ((parent major-mode)) 1013 (let ((parent major-mode))
1036 (while (and (not (memq parent modes)) 1014 (while (and (not (memq parent modes))
1037 (setq parent (get parent 'derived-mode-parent)))) 1015 (setq parent (get parent 'derived-mode-parent))))
1038 parent)))) 1016 parent))))
1039 1017
1040;;;###autoload 1018;;;###autoload
1041(defun epa-encrypt-region (start end recipients sign signers) 1019(defun epa-encrypt-region (start end recipients sign signers)
@@ -1138,6 +1116,7 @@ If no one is selected, symmetric encryption will be performed. ")
1138 (if (epg-context-result-for context 'import) 1116 (if (epg-context-result-for context 'import)
1139 (epa-display-info (epg-import-result-to-string 1117 (epa-display-info (epg-import-result-to-string
1140 (epg-context-result-for context 'import)))) 1118 (epg-context-result-for context 'import))))
1119 ;; FIXME: Why not use the (otherwise unused) epa--derived-mode-p?
1141 (if (eq major-mode 'epa-key-list-mode) 1120 (if (eq major-mode 'epa-key-list-mode)
1142 (apply #'epa--list-keys epa-list-keys-arguments)))) 1121 (apply #'epa--list-keys epa-list-keys-arguments))))
1143 1122
diff --git a/lisp/epg.el b/lisp/epg.el
index bcd91d8abba..c733a273988 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -2415,9 +2415,8 @@ If you are unsure, use synchronous version of this function
2415 (list "--" (epg-data-file plain))))) 2415 (list "--" (epg-data-file plain)))))
2416 ;; `gpgsm' does not read passphrase from stdin, so waiting is not needed. 2416 ;; `gpgsm' does not read passphrase from stdin, so waiting is not needed.
2417 (unless (eq (epg-context-protocol context) 'CMS) 2417 (unless (eq (epg-context-protocol context) 'CMS)
2418 (if sign 2418 (epg-wait-for-status context
2419 (epg-wait-for-status context '("BEGIN_SIGNING")) 2419 (if sign '("BEGIN_SIGNING") '("BEGIN_ENCRYPTION"))))
2420 (epg-wait-for-status context '("BEGIN_ENCRYPTION"))))
2421 (when (epg-data-string plain) 2420 (when (epg-data-string plain)
2422 (if (eq (process-status (epg-context-process context)) 'run) 2421 (if (eq (process-status (epg-context-process context)) 'run)
2423 (process-send-string (epg-context-process context) 2422 (process-send-string (epg-context-process context)
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 104e3363831..9aec829cd97 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -158,11 +158,13 @@ minibuffer completion.")
158(add-hook 'icomplete-post-command-hook 'icomplete-exhibit) 158(add-hook 'icomplete-post-command-hook 'icomplete-exhibit)
159 159
160;;;_ = icomplete-with-completion-tables 160;;;_ = icomplete-with-completion-tables
161(defvar icomplete-with-completion-tables '(internal-complete-buffer) 161(defcustom icomplete-with-completion-tables t
162 "Specialized completion tables with which icomplete should operate. 162 "Specialized completion tables with which icomplete should operate.
163 163
164Icomplete does not operate with any specialized completion tables 164Icomplete does not operate with any specialized completion tables
165except those on this list.") 165except those on this list."
166 :type '(choice (const :tag "All" t)
167 (repeat function)))
166 168
167(defvar icomplete-minibuffer-map 169(defvar icomplete-minibuffer-map
168 (let ((map (make-sparse-keymap))) 170 (let ((map (make-sparse-keymap)))
@@ -177,24 +179,28 @@ except those on this list.")
177Second entry becomes the first and can be selected with 179Second entry becomes the first and can be selected with
178`minibuffer-force-complete-and-exit'." 180`minibuffer-force-complete-and-exit'."
179 (interactive) 181 (interactive)
180 (let* ((comps (completion-all-sorted-completions)) 182 (let* ((beg (minibuffer-prompt-end))
183 (end (point-max))
184 (comps (completion-all-sorted-completions beg end))
181 (last (last comps))) 185 (last (last comps)))
182 (when comps 186 (when comps
183 (setcdr last (cons (car comps) (cdr last))) 187 (setcdr last (cons (car comps) (cdr last)))
184 (completion--cache-all-sorted-completions (cdr comps))))) 188 (completion--cache-all-sorted-completions beg end (cdr comps)))))
185 189
186(defun icomplete-backward-completions () 190(defun icomplete-backward-completions ()
187 "Step backward completions by one entry. 191 "Step backward completions by one entry.
188Last entry becomes the first and can be selected with 192Last entry becomes the first and can be selected with
189`minibuffer-force-complete-and-exit'." 193`minibuffer-force-complete-and-exit'."
190 (interactive) 194 (interactive)
191 (let* ((comps (completion-all-sorted-completions)) 195 (let* ((beg (minibuffer-prompt-end))
196 (end (point-max))
197 (comps (completion-all-sorted-completions beg end))
192 (last-but-one (last comps 2)) 198 (last-but-one (last comps 2))
193 (last (cdr last-but-one))) 199 (last (cdr last-but-one)))
194 (when (consp last) ; At least two elements in comps 200 (when (consp last) ; At least two elements in comps
195 (setcdr last-but-one (cdr last)) 201 (setcdr last-but-one (cdr last))
196 (push (car last) comps) 202 (push (car last) comps)
197 (completion--cache-all-sorted-completions comps)))) 203 (completion--cache-all-sorted-completions beg end comps))))
198 204
199;;;_ > icomplete-mode (&optional prefix) 205;;;_ > icomplete-mode (&optional prefix)
200;;;###autoload 206;;;###autoload
@@ -263,7 +269,8 @@ and `minibuffer-setup-hook'."
263 "Insert icomplete completions display. 269 "Insert icomplete completions display.
264Should be run via minibuffer `post-command-hook'. See `icomplete-mode' 270Should be run via minibuffer `post-command-hook'. See `icomplete-mode'
265and `minibuffer-setup-hook'." 271and `minibuffer-setup-hook'."
266 (when (and icomplete-mode (icomplete-simple-completing-p)) 272 (when (and icomplete-mode
273 (icomplete-simple-completing-p)) ;Shouldn't be necessary.
267 (save-excursion 274 (save-excursion
268 (goto-char (point-max)) 275 (goto-char (point-max))
269 ; Insert the match-status information: 276 ; Insert the match-status information:
@@ -319,7 +326,8 @@ matches exist. \(Keybindings for uniquely matched commands
319are exhibited within the square braces.)" 326are exhibited within the square braces.)"
320 327
321 (let* ((md (completion--field-metadata (field-beginning))) 328 (let* ((md (completion--field-metadata (field-beginning)))
322 (comps (completion-all-sorted-completions)) 329 (comps (completion-all-sorted-completions
330 (minibuffer-prompt-end) (point-max)))
323 (last (if (consp comps) (last comps))) 331 (last (if (consp comps) (last comps)))
324 (base-size (cdr last)) 332 (base-size (cdr last))
325 (open-bracket (if require-match "(" "[")) 333 (open-bracket (if require-match "(" "["))
diff --git a/lisp/info.el b/lisp/info.el
index 182ad8563aa..65cd7eddcfd 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1595,17 +1595,20 @@ escaped (\\\",\\\\)."
1595 "")) 1595 ""))
1596 (image (if (file-exists-p image-file) 1596 (image (if (file-exists-p image-file)
1597 (create-image image-file) 1597 (create-image image-file)
1598 "[broken image]"))) 1598 (or (cdr (assoc-string "text" parameter-alist))
1599 (and src (concat "[broken image:" src "]"))
1600 "[broken image]"))))
1599 (if (not (get-text-property start 'display)) 1601 (if (not (get-text-property start 'display))
1600 (add-text-properties 1602 (add-text-properties
1601 start (point) `(display ,image rear-nonsticky (display))))) 1603 start (point)
1604 `(display ,image rear-nonsticky (display)
1605 help-echo ,(cdr (assoc-string "alt" parameter-alist))))))
1602 ;; text-only display, show alternative text if provided, or 1606 ;; text-only display, show alternative text if provided, or
1603 ;; otherwise a clue that there's meant to be a picture 1607 ;; otherwise a clue that there's meant to be a picture
1604 (delete-region start (point)) 1608 (delete-region start (point))
1605 (insert (or (cdr (assoc-string "text" parameter-alist)) 1609 (insert (or (cdr (assoc-string "text" parameter-alist))
1606 (cdr (assoc-string "alt" parameter-alist)) 1610 (cdr (assoc-string "alt" parameter-alist))
1607 (and src 1611 (and src (concat "[image:" src "]"))
1608 (concat "[image:" src "]"))
1609 "[image]")))))) 1612 "[image]"))))))
1610 (set-buffer-modified-p nil))) 1613 (set-buffer-modified-p nil)))
1611 1614
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index e07d28a54d0..c505a74c23d 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -38,7 +38,7 @@
38 38
39;;; Bugs: 39;;; Bugs:
40 40
41;; - completion-all-sorted-completions list all the completions, whereas 41;; - completion-all-sorted-completions lists all the completions, whereas
42;; it should only lists the ones that `try-completion' would consider. 42;; it should only lists the ones that `try-completion' would consider.
43;; E.g. it should honor completion-ignored-extensions. 43;; E.g. it should honor completion-ignored-extensions.
44;; - choose-completion can't automatically figure out the boundaries 44;; - choose-completion can't automatically figure out the boundaries
@@ -145,7 +145,7 @@ Like CL's `some'."
145 (let ((firsterror nil) 145 (let ((firsterror nil)
146 res) 146 res)
147 (while (and (not res) xs) 147 (while (and (not res) xs)
148 (condition-case err 148 (condition-case-unless-debug err
149 (setq res (funcall fun (pop xs))) 149 (setq res (funcall fun (pop xs)))
150 (error (unless firsterror (setq firsterror err)) nil))) 150 (error (unless firsterror (setq firsterror err)) nil)))
151 (or res 151 (or res
@@ -623,7 +623,8 @@ If ARGS are provided, then pass MESSAGE through `format'."
623 (message nil))) 623 (message nil)))
624 ;; Clear out any old echo-area message to make way for our new thing. 624 ;; Clear out any old echo-area message to make way for our new thing.
625 (message nil) 625 (message nil)
626 (setq message (if (and (null args) (string-match-p "\\` *\\[.+\\]\\'" message)) 626 (setq message (if (and (null args)
627 (string-match-p "\\` *\\[.+\\]\\'" message))
627 ;; Make sure we can put-text-property. 628 ;; Make sure we can put-text-property.
628 (copy-sequence message) 629 (copy-sequence message)
629 (concat " [" message "]"))) 630 (concat " [" message "]")))
@@ -651,7 +652,7 @@ If ARGS are provided, then pass MESSAGE through `format'."
651 "Return the user input in a minibuffer before point as a string. 652 "Return the user input in a minibuffer before point as a string.
652In Emacs-22, that was what completion commands operated on." 653In Emacs-22, that was what completion commands operated on."
653 (declare (obsolete nil "24.4")) 654 (declare (obsolete nil "24.4"))
654 (buffer-substring (field-beginning) (point))) 655 (buffer-substring (minibuffer-prompt-end) (point)))
655 656
656(defun delete-minibuffer-contents () 657(defun delete-minibuffer-contents ()
657 "Delete all user input in a minibuffer. 658 "Delete all user input in a minibuffer.
@@ -670,8 +671,7 @@ If the value is t the *Completion* buffer is displayed whenever completion
670is requested but cannot be done. 671is requested but cannot be done.
671If the value is `lazy', the *Completions* buffer is only displayed after 672If the value is `lazy', the *Completions* buffer is only displayed after
672the second failed attempt to complete." 673the second failed attempt to complete."
673 :type '(choice (const nil) (const t) (const lazy)) 674 :type '(choice (const nil) (const t) (const lazy)))
674 :group 'minibuffer)
675 675
676(defconst completion-styles-alist 676(defconst completion-styles-alist
677 '((emacs21 677 '((emacs21
@@ -750,7 +750,6 @@ The available styles are listed in `completion-styles-alist'.
750Note that `completion-category-overrides' may override these 750Note that `completion-category-overrides' may override these
751styles for specific categories, such as files, buffers, etc." 751styles for specific categories, such as files, buffers, etc."
752 :type completion--styles-type 752 :type completion--styles-type
753 :group 'minibuffer
754 :version "23.1") 753 :version "23.1")
755 754
756(defcustom completion-category-overrides 755(defcustom completion-category-overrides
@@ -880,7 +879,7 @@ Moves point to the end of the new text."
880 879
881(defcustom completion-cycle-threshold nil 880(defcustom completion-cycle-threshold nil
882 "Number of completion candidates below which cycling is used. 881 "Number of completion candidates below which cycling is used.
883Depending on this setting `minibuffer-complete' may use cycling, 882Depending on this setting `completion-in-region' may use cycling,
884like `minibuffer-force-complete'. 883like `minibuffer-force-complete'.
885If nil, cycling is never used. 884If nil, cycling is never used.
886If t, cycling is always used. 885If t, cycling is always used.
@@ -894,8 +893,7 @@ completion candidates than this number."
894 (over (assq 'cycle (cdr (assq cat completion-category-overrides))))) 893 (over (assq 'cycle (cdr (assq cat completion-category-overrides)))))
895 (if over (cdr over) completion-cycle-threshold))) 894 (if over (cdr over) completion-cycle-threshold)))
896 895
897(defvar completion-all-sorted-completions nil) 896(defvar-local completion-all-sorted-completions nil)
898(make-variable-buffer-local 'completion-all-sorted-completions)
899(defvar-local completion--all-sorted-completions-location nil) 897(defvar-local completion--all-sorted-completions-location nil)
900(defvar completion-cycling nil) 898(defvar completion-cycling nil)
901 899
@@ -906,8 +904,8 @@ completion candidates than this number."
906 (if completion-show-inline-help 904 (if completion-show-inline-help
907 (minibuffer-message msg))) 905 (minibuffer-message msg)))
908 906
909(defun completion--do-completion (&optional try-completion-function 907(defun completion--do-completion (beg end &optional
910 expect-exact) 908 try-completion-function expect-exact)
911 "Do the completion and return a summary of what happened. 909 "Do the completion and return a summary of what happened.
912M = completion was performed, the text was Modified. 910M = completion was performed, the text was Modified.
913C = there were available Completions. 911C = there were available Completions.
@@ -926,9 +924,7 @@ E = after completion we now have an Exact match.
926TRY-COMPLETION-FUNCTION is a function to use in place of `try-completion'. 924TRY-COMPLETION-FUNCTION is a function to use in place of `try-completion'.
927EXPECT-EXACT, if non-nil, means that there is no need to tell the user 925EXPECT-EXACT, if non-nil, means that there is no need to tell the user
928when the buffer's text is already an exact match." 926when the buffer's text is already an exact match."
929 (let* ((beg (field-beginning)) 927 (let* ((string (buffer-substring beg end))
930 (end (field-end))
931 (string (buffer-substring beg end))
932 (md (completion--field-metadata beg)) 928 (md (completion--field-metadata beg))
933 (comp (funcall (or try-completion-function 929 (comp (funcall (or try-completion-function
934 'completion-try-completion) 930 'completion-try-completion)
@@ -963,7 +959,8 @@ when the buffer's text is already an exact match."
963 (if unchanged 959 (if unchanged
964 (goto-char end) 960 (goto-char end)
965 ;; Insert in minibuffer the chars we got. 961 ;; Insert in minibuffer the chars we got.
966 (completion--replace beg end completion)) 962 (completion--replace beg end completion)
963 (setq end (+ beg (length completion))))
967 ;; Move point to its completion-mandated destination. 964 ;; Move point to its completion-mandated destination.
968 (forward-char (- comp-pos (length completion))) 965 (forward-char (- comp-pos (length completion)))
969 966
@@ -972,7 +969,8 @@ when the buffer's text is already an exact match."
972 ;; whether this is a unique completion or not, so try again using 969 ;; whether this is a unique completion or not, so try again using
973 ;; the real case (this shouldn't recurse again, because the next 970 ;; the real case (this shouldn't recurse again, because the next
974 ;; time try-completion will return either t or the exact string). 971 ;; time try-completion will return either t or the exact string).
975 (completion--do-completion try-completion-function expect-exact) 972 (completion--do-completion beg end
973 try-completion-function expect-exact)
976 974
977 ;; It did find a match. Do we match some possibility exactly now? 975 ;; It did find a match. Do we match some possibility exactly now?
978 (let* ((exact (test-completion completion 976 (let* ((exact (test-completion completion
@@ -995,7 +993,7 @@ when the buffer's text is already an exact match."
995 minibuffer-completion-predicate 993 minibuffer-completion-predicate
996 "")) 994 ""))
997 comp-pos))) 995 comp-pos)))
998 (completion-all-sorted-completions)))) 996 (completion-all-sorted-completions beg end))))
999 (completion--flush-all-sorted-completions) 997 (completion--flush-all-sorted-completions)
1000 (cond 998 (cond
1001 ((and (consp (cdr comps)) ;; There's something to cycle. 999 ((and (consp (cdr comps)) ;; There's something to cycle.
@@ -1006,8 +1004,8 @@ when the buffer's text is already an exact match."
1006 ;; Not more than completion-cycle-threshold remaining 1004 ;; Not more than completion-cycle-threshold remaining
1007 ;; completions: let's cycle. 1005 ;; completions: let's cycle.
1008 (setq completed t exact t) 1006 (setq completed t exact t)
1009 (completion--cache-all-sorted-completions comps) 1007 (completion--cache-all-sorted-completions beg end comps)
1010 (minibuffer-force-complete)) 1008 (minibuffer-force-complete beg end))
1011 (completed 1009 (completed
1012 ;; We could also decide to refresh the completions, 1010 ;; We could also decide to refresh the completions,
1013 ;; if they're displayed (and assuming there are 1011 ;; if they're displayed (and assuming there are
@@ -1024,14 +1022,14 @@ when the buffer's text is already an exact match."
1024 (if (pcase completion-auto-help 1022 (if (pcase completion-auto-help
1025 (`lazy (eq this-command last-command)) 1023 (`lazy (eq this-command last-command))
1026 (_ completion-auto-help)) 1024 (_ completion-auto-help))
1027 (minibuffer-completion-help) 1025 (minibuffer-completion-help beg end)
1028 (completion--message "Next char not unique"))) 1026 (completion--message "Next char not unique")))
1029 ;; If the last exact completion and this one were the same, it 1027 ;; If the last exact completion and this one were the same, it
1030 ;; means we've already given a "Complete, but not unique" message 1028 ;; means we've already given a "Complete, but not unique" message
1031 ;; and the user's hit TAB again, so now we give him help. 1029 ;; and the user's hit TAB again, so now we give him help.
1032 (t 1030 (t
1033 (if (and (eq this-command last-command) completion-auto-help) 1031 (if (and (eq this-command last-command) completion-auto-help)
1034 (minibuffer-completion-help)) 1032 (minibuffer-completion-help beg end))
1035 (completion--done completion 'exact 1033 (completion--done completion 'exact
1036 (unless expect-exact 1034 (unless expect-exact
1037 "Complete, but not unique")))) 1035 "Complete, but not unique"))))
@@ -1045,6 +1043,11 @@ If no characters can be completed, display a list of possible completions.
1045If you repeat this command after it displayed such a list, 1043If you repeat this command after it displayed such a list,
1046scroll the window of possible completions." 1044scroll the window of possible completions."
1047 (interactive) 1045 (interactive)
1046 (completion-in-region (minibuffer-prompt-end) (point-max)
1047 minibuffer-completion-table
1048 minibuffer-completion-predicate))
1049
1050(defun completion--in-region-1 (beg end)
1048 ;; If the previous command was not this, 1051 ;; If the previous command was not this,
1049 ;; mark the completion buffer obsolete. 1052 ;; mark the completion buffer obsolete.
1050 (setq this-command 'completion-at-point) 1053 (setq this-command 'completion-at-point)
@@ -1067,17 +1070,17 @@ scroll the window of possible completions."
1067 nil))) 1070 nil)))
1068 ;; If we're cycling, keep on cycling. 1071 ;; If we're cycling, keep on cycling.
1069 ((and completion-cycling completion-all-sorted-completions) 1072 ((and completion-cycling completion-all-sorted-completions)
1070 (minibuffer-force-complete) 1073 (minibuffer-force-complete beg end)
1071 t) 1074 t)
1072 (t (pcase (completion--do-completion) 1075 (t (pcase (completion--do-completion beg end)
1073 (#b000 nil) 1076 (#b000 nil)
1074 (_ t))))) 1077 (_ t)))))
1075 1078
1076(defun completion--cache-all-sorted-completions (comps) 1079(defun completion--cache-all-sorted-completions (beg end comps)
1077 (add-hook 'after-change-functions 1080 (add-hook 'after-change-functions
1078 'completion--flush-all-sorted-completions nil t) 1081 'completion--flush-all-sorted-completions nil t)
1079 (setq completion--all-sorted-completions-location 1082 (setq completion--all-sorted-completions-location
1080 (cons (copy-marker (field-beginning)) (copy-marker (field-end)))) 1083 (cons (copy-marker beg) (copy-marker end)))
1081 (setq completion-all-sorted-completions comps)) 1084 (setq completion-all-sorted-completions comps))
1082 1085
1083(defun completion--flush-all-sorted-completions (&optional start end _len) 1086(defun completion--flush-all-sorted-completions (&optional start end _len)
@@ -1097,10 +1100,10 @@ scroll the window of possible completions."
1097 (if (eq (car bounds) base) md-at-point 1100 (if (eq (car bounds) base) md-at-point
1098 (completion-metadata (substring string 0 base) table pred)))) 1101 (completion-metadata (substring string 0 base) table pred))))
1099 1102
1100(defun completion-all-sorted-completions () 1103(defun completion-all-sorted-completions (start end)
1101 (or completion-all-sorted-completions 1104 (or completion-all-sorted-completions
1102 (let* ((start (field-beginning)) 1105 (let* ((start (or start (minibuffer-prompt-end)))
1103 (end (field-end)) 1106 (end (or end (point-max)))
1104 (string (buffer-substring start end)) 1107 (string (buffer-substring start end))
1105 (md (completion--field-metadata start)) 1108 (md (completion--field-metadata start))
1106 (all (completion-all-completions 1109 (all (completion-all-completions
@@ -1138,18 +1141,20 @@ scroll the window of possible completions."
1138 ;; Cache the result. This is not just for speed, but also so that 1141 ;; Cache the result. This is not just for speed, but also so that
1139 ;; repeated calls to minibuffer-force-complete can cycle through 1142 ;; repeated calls to minibuffer-force-complete can cycle through
1140 ;; all possibilities. 1143 ;; all possibilities.
1141 (completion--cache-all-sorted-completions (nconc all base-size)))))) 1144 (completion--cache-all-sorted-completions
1145 start end (nconc all base-size))))))
1142 1146
1143(defun minibuffer-force-complete-and-exit () 1147(defun minibuffer-force-complete-and-exit ()
1144 "Complete the minibuffer with first of the matches and exit." 1148 "Complete the minibuffer with first of the matches and exit."
1145 (interactive) 1149 (interactive)
1146 (minibuffer-force-complete) 1150 (minibuffer-force-complete)
1147 (minibuffer--complete-and-exit 1151 (completion--complete-and-exit
1152 (minibuffer-prompt-end) (point-max) #'exit-minibuffer
1148 ;; If the previous completion completed to an element which fails 1153 ;; If the previous completion completed to an element which fails
1149 ;; test-completion, then we shouldn't exit, but that should be rare. 1154 ;; test-completion, then we shouldn't exit, but that should be rare.
1150 (lambda () (minibuffer-message "Incomplete")))) 1155 (lambda () (minibuffer-message "Incomplete"))))
1151 1156
1152(defun minibuffer-force-complete () 1157(defun minibuffer-force-complete (&optional start end)
1153 "Complete the minibuffer to an exact match. 1158 "Complete the minibuffer to an exact match.
1154Repeated uses step through the possible completions." 1159Repeated uses step through the possible completions."
1155 (interactive) 1160 (interactive)
@@ -1157,10 +1162,10 @@ Repeated uses step through the possible completions."
1157 ;; FIXME: Need to deal with the extra-size issue here as well. 1162 ;; FIXME: Need to deal with the extra-size issue here as well.
1158 ;; FIXME: ~/src/emacs/t<M-TAB>/lisp/minibuffer.el completes to 1163 ;; FIXME: ~/src/emacs/t<M-TAB>/lisp/minibuffer.el completes to
1159 ;; ~/src/emacs/trunk/ and throws away lisp/minibuffer.el. 1164 ;; ~/src/emacs/trunk/ and throws away lisp/minibuffer.el.
1160 (let* ((start (copy-marker (field-beginning))) 1165 (let* ((start (copy-marker (or start (minibuffer-prompt-end))))
1161 (end (field-end)) 1166 (end (or end (point-max)))
1162 ;; (md (completion--field-metadata start)) 1167 ;; (md (completion--field-metadata start))
1163 (all (completion-all-sorted-completions)) 1168 (all (completion-all-sorted-completions start end))
1164 (base (+ start (or (cdr (last all)) 0)))) 1169 (base (+ start (or (cdr (last all)) 0))))
1165 (cond 1170 (cond
1166 ((not (consp all)) 1171 ((not (consp all))
@@ -1173,10 +1178,11 @@ Repeated uses step through the possible completions."
1173 'finished (when done "Sole completion")))) 1178 'finished (when done "Sole completion"))))
1174 (t 1179 (t
1175 (completion--replace base end (car all)) 1180 (completion--replace base end (car all))
1181 (setq end (+ base (length (car all))))
1176 (completion--done (buffer-substring-no-properties start (point)) 'sole) 1182 (completion--done (buffer-substring-no-properties start (point)) 'sole)
1177 ;; Set cycling after modifying the buffer since the flush hook resets it. 1183 ;; Set cycling after modifying the buffer since the flush hook resets it.
1178 (setq completion-cycling t) 1184 (setq completion-cycling t)
1179 (setq this-command 'completion-at-point) ;For minibuffer-complete. 1185 (setq this-command 'completion-at-point) ;For completion-in-region.
1180 ;; If completing file names, (car all) may be a directory, so we'd now 1186 ;; If completing file names, (car all) may be a directory, so we'd now
1181 ;; have a new set of possible completions and might want to reset 1187 ;; have a new set of possible completions and might want to reset
1182 ;; completion-all-sorted-completions to nil, but we prefer not to, 1188 ;; completion-all-sorted-completions to nil, but we prefer not to,
@@ -1184,7 +1190,7 @@ Repeated uses step through the possible completions."
1184 ;; through the previous possible completions. 1190 ;; through the previous possible completions.
1185 (let ((last (last all))) 1191 (let ((last (last all)))
1186 (setcdr last (cons (car all) (cdr last))) 1192 (setcdr last (cons (car all) (cdr last)))
1187 (completion--cache-all-sorted-completions (cdr all))) 1193 (completion--cache-all-sorted-completions start end (cdr all)))
1188 ;; Make sure repeated uses cycle, even though completion--done might 1194 ;; Make sure repeated uses cycle, even though completion--done might
1189 ;; have added a space or something that moved us outside of the field. 1195 ;; have added a space or something that moved us outside of the field.
1190 ;; (bug#12221). 1196 ;; (bug#12221).
@@ -1223,27 +1229,32 @@ If `minibuffer-completion-confirm' is `confirm-after-completion',
1223 `minibuffer-confirm-exit-commands', and accept the input 1229 `minibuffer-confirm-exit-commands', and accept the input
1224 otherwise." 1230 otherwise."
1225 (interactive) 1231 (interactive)
1226 (minibuffer--complete-and-exit 1232 (completion-complete-and-exit (minibuffer-prompt-end) (point-max)
1233 #'exit-minibuffer))
1234
1235(defun completion-complete-and-exit (beg end exit-function)
1236 (completion--complete-and-exit
1237 beg end exit-function
1227 (lambda () 1238 (lambda ()
1228 (pcase (condition-case nil 1239 (pcase (condition-case nil
1229 (completion--do-completion nil 'expect-exact) 1240 (completion--do-completion beg end
1241 nil 'expect-exact)
1230 (error 1)) 1242 (error 1))
1231 ((or #b001 #b011) (exit-minibuffer)) 1243 ((or #b001 #b011) (funcall exit-function))
1232 (#b111 (if (not minibuffer-completion-confirm) 1244 (#b111 (if (not minibuffer-completion-confirm)
1233 (exit-minibuffer) 1245 (funcall exit-function)
1234 (minibuffer-message "Confirm") 1246 (minibuffer-message "Confirm")
1235 nil)) 1247 nil))
1236 (_ nil))))) 1248 (_ nil)))))
1237 1249
1238(defun minibuffer--complete-and-exit (completion-function) 1250(defun completion--complete-and-exit (beg end
1251 exit-function completion-function)
1239 "Exit from `require-match' minibuffer. 1252 "Exit from `require-match' minibuffer.
1240COMPLETION-FUNCTION is called if the current buffer's content does not 1253COMPLETION-FUNCTION is called if the current buffer's content does not
1241appear to be a match." 1254appear to be a match."
1242 (let ((beg (field-beginning))
1243 (end (field-end)))
1244 (cond 1255 (cond
1245 ;; Allow user to specify null string 1256 ;; Allow user to specify null string
1246 ((= beg end) (exit-minibuffer)) 1257 ((= beg end) (funcall exit-function))
1247 ((test-completion (buffer-substring beg end) 1258 ((test-completion (buffer-substring beg end)
1248 minibuffer-completion-table 1259 minibuffer-completion-table
1249 minibuffer-completion-predicate) 1260 minibuffer-completion-predicate)
@@ -1269,7 +1280,7 @@ appear to be a match."
1269 ;; that file. 1280 ;; that file.
1270 (= (length string) (length compl))) 1281 (= (length string) (length compl)))
1271 (completion--replace beg end compl)))) 1282 (completion--replace beg end compl))))
1272 (exit-minibuffer)) 1283 (funcall exit-function))
1273 1284
1274 ((memq minibuffer-completion-confirm '(confirm confirm-after-completion)) 1285 ((memq minibuffer-completion-confirm '(confirm confirm-after-completion))
1275 ;; The user is permitted to exit with an input that's rejected 1286 ;; The user is permitted to exit with an input that's rejected
@@ -1280,13 +1291,13 @@ appear to be a match."
1280 ;; catches most minibuffer typos). 1291 ;; catches most minibuffer typos).
1281 (and (eq minibuffer-completion-confirm 'confirm-after-completion) 1292 (and (eq minibuffer-completion-confirm 'confirm-after-completion)
1282 (not (memq last-command minibuffer-confirm-exit-commands)))) 1293 (not (memq last-command minibuffer-confirm-exit-commands))))
1283 (exit-minibuffer) 1294 (funcall exit-function)
1284 (minibuffer-message "Confirm") 1295 (minibuffer-message "Confirm")
1285 nil)) 1296 nil))
1286 1297
1287 (t 1298 (t
1288 ;; Call do-completion, but ignore errors. 1299 ;; Call do-completion, but ignore errors.
1289 (funcall completion-function))))) 1300 (funcall completion-function))))
1290 1301
1291(defun completion--try-word-completion (string table predicate point md) 1302(defun completion--try-word-completion (string table predicate point md)
1292 (let ((comp (completion-try-completion string table predicate point md))) 1303 (let ((comp (completion-try-completion string table predicate point md)))
@@ -1381,9 +1392,18 @@ After one word is completed as much as possible, a space or hyphen
1381is added, provided that matches some possible completion. 1392is added, provided that matches some possible completion.
1382Return nil if there is no valid completion, else t." 1393Return nil if there is no valid completion, else t."
1383 (interactive) 1394 (interactive)
1384 (pcase (completion--do-completion 'completion--try-word-completion) 1395 (completion-in-region--single-word
1396 (minibuffer-prompt-end) (point-max)
1397 minibuffer-completion-table minibuffer-completion-predicate))
1398
1399(defun completion-in-region--single-word (beg end collection
1400 &optional predicate)
1401 (let ((minibuffer-completion-table collection)
1402 (minibuffer-completion-predicate predicate))
1403 (pcase (completion--do-completion beg end
1404 #'completion--try-word-completion)
1385 (#b000 nil) 1405 (#b000 nil)
1386 (_ t))) 1406 (_ t))))
1387 1407
1388(defface completions-annotations '((t :inherit italic)) 1408(defface completions-annotations '((t :inherit italic))
1389 "Face to use for annotations in the *Completions* buffer.") 1409 "Face to use for annotations in the *Completions* buffer.")
@@ -1395,7 +1415,6 @@ in columns in the *Completions* buffer.
1395If the value is `horizontal', display completions sorted 1415If the value is `horizontal', display completions sorted
1396horizontally in alphabetical order, rather than down the screen." 1416horizontally in alphabetical order, rather than down the screen."
1397 :type '(choice (const horizontal) (const vertical)) 1417 :type '(choice (const horizontal) (const vertical))
1398 :group 'minibuffer
1399 :version "23.2") 1418 :version "23.2")
1400 1419
1401(defun completion--insert-strings (strings) 1420(defun completion--insert-strings (strings)
@@ -1504,15 +1523,13 @@ See also `display-completion-list'.")
1504 1523
1505(defface completions-first-difference 1524(defface completions-first-difference
1506 '((t (:inherit bold))) 1525 '((t (:inherit bold)))
1507 "Face added on the first uncommon character in completions in *Completions* buffer." 1526 "Face added on the first uncommon character in completions in *Completions* buffer.")
1508 :group 'completion)
1509 1527
1510(defface completions-common-part '((t nil)) 1528(defface completions-common-part '((t nil))
1511 "Face added on the common prefix substring in completions in *Completions* buffer. 1529 "Face added on the common prefix substring in completions in *Completions* buffer.
1512The idea of `completions-common-part' is that you can use it to 1530The idea of `completions-common-part' is that you can use it to
1513make the common parts less visible than normal, so that the rest 1531make the common parts less visible than normal, so that the rest
1514of the differing parts is, by contrast, slightly highlighted." 1532of the differing parts is, by contrast, slightly highlighted.")
1515 :group 'completion)
1516 1533
1517(defun completion-hilit-commonality (completions prefix-len base-size) 1534(defun completion-hilit-commonality (completions prefix-len base-size)
1518 (when completions 1535 (when completions
@@ -1555,12 +1572,8 @@ alternative, the second serves as annotation.
1555The actual completion alternatives, as inserted, are given `mouse-face' 1572The actual completion alternatives, as inserted, are given `mouse-face'
1556properties of `highlight'. 1573properties of `highlight'.
1557At the end, this runs the normal hook `completion-setup-hook'. 1574At the end, this runs the normal hook `completion-setup-hook'.
1558It can find the completion buffer in `standard-output'. 1575It can find the completion buffer in `standard-output'."
1559 1576 (declare (advertised-calling-convention (completions) "24.4"))
1560The obsolete optional arg COMMON-SUBSTRING, if non-nil, should be a string
1561specifying a common substring for adding the faces
1562`completions-first-difference' and `completions-common-part' to
1563the completions buffer."
1564 (if common-substring 1577 (if common-substring
1565 (setq completions (completion-hilit-commonality 1578 (setq completions (completion-hilit-commonality
1566 completions (length common-substring) 1579 completions (length common-substring)
@@ -1647,19 +1660,19 @@ variables.")
1647 (equal pre-msg (and exit-fun (current-message)))) 1660 (equal pre-msg (and exit-fun (current-message))))
1648 (completion--message message)))) 1661 (completion--message message))))
1649 1662
1650(defun minibuffer-completion-help () 1663(defun minibuffer-completion-help (&optional start end)
1651 "Display a list of possible completions of the current minibuffer contents." 1664 "Display a list of possible completions of the current minibuffer contents."
1652 (interactive) 1665 (interactive)
1653 (message "Making completion list...") 1666 (message "Making completion list...")
1654 (let* ((start (field-beginning)) 1667 (let* ((start (or start (minibuffer-prompt-end)))
1655 (end (field-end)) 1668 (end (or end (point-max)))
1656 (string (field-string)) 1669 (string (buffer-substring start end))
1657 (md (completion--field-metadata start)) 1670 (md (completion--field-metadata start))
1658 (completions (completion-all-completions 1671 (completions (completion-all-completions
1659 string 1672 string
1660 minibuffer-completion-table 1673 minibuffer-completion-table
1661 minibuffer-completion-predicate 1674 minibuffer-completion-predicate
1662 (- (point) (field-beginning)) 1675 (- (point) start)
1663 md))) 1676 md)))
1664 (message nil) 1677 (message nil)
1665 (if (or (null completions) 1678 (if (or (null completions)
@@ -1811,7 +1824,6 @@ exit."
1811 (if (memq system-type '(ms-dos windows-nt darwin cygwin)) 1824 (if (memq system-type '(ms-dos windows-nt darwin cygwin))
1812 t nil) 1825 t nil)
1813 "Non-nil means when reading a file name completion ignores case." 1826 "Non-nil means when reading a file name completion ignores case."
1814 :group 'minibuffer
1815 :type 'boolean 1827 :type 'boolean
1816 :version "22.1") 1828 :version "22.1")
1817 1829
@@ -1821,22 +1833,15 @@ exit."
1821 ;; completions" operation as well. 1833 ;; completions" operation as well.
1822 completion-in-region-functions (start end collection predicate) 1834 completion-in-region-functions (start end collection predicate)
1823 (let ((minibuffer-completion-table collection) 1835 (let ((minibuffer-completion-table collection)
1824 (minibuffer-completion-predicate predicate) 1836 (minibuffer-completion-predicate predicate))
1825 (ol (make-overlay start end nil nil t)))
1826 (overlay-put ol 'field 'completion)
1827 ;; HACK: if the text we are completing is already in a field, we 1837 ;; HACK: if the text we are completing is already in a field, we
1828 ;; want the completion field to take priority (e.g. Bug#6830). 1838 ;; want the completion field to take priority (e.g. Bug#6830).
1829 (overlay-put ol 'priority 100)
1830 (when completion-in-region-mode-predicate 1839 (when completion-in-region-mode-predicate
1831 (completion-in-region-mode 1) 1840 (completion-in-region-mode 1)
1832 (setq completion-in-region--data 1841 (setq completion-in-region--data
1833 (list (if (markerp start) start (copy-marker start)) 1842 (list (if (markerp start) start (copy-marker start))
1834 (copy-marker end) collection))) 1843 (copy-marker end) collection)))
1835 ;; FIXME: `minibuffer-complete' should call `completion-in-region' rather 1844 (completion--in-region-1 start end))))
1836 ;; than the other way around!
1837 (unwind-protect
1838 (call-interactively 'minibuffer-complete)
1839 (delete-overlay ol)))))
1840 1845
1841(defvar completion-in-region-mode-map 1846(defvar completion-in-region-mode-map
1842 (let ((map (make-sparse-keymap))) 1847 (let ((map (make-sparse-keymap)))
@@ -2001,19 +2006,14 @@ The completion method is determined by `completion-at-point-functions'."
2001 (lambda () 2006 (lambda ()
2002 ;; We're still in the same completion field. 2007 ;; We're still in the same completion field.
2003 (let ((newstart (car-safe (funcall hookfun)))) 2008 (let ((newstart (car-safe (funcall hookfun))))
2004 (and newstart (= newstart start))))) 2009 (and newstart (= newstart start))))))
2005 (ol (make-overlay start end nil nil t)))
2006 ;; FIXME: We should somehow (ab)use completion-in-region-function or 2010 ;; FIXME: We should somehow (ab)use completion-in-region-function or
2007 ;; introduce a corresponding hook (plus another for word-completion, 2011 ;; introduce a corresponding hook (plus another for word-completion,
2008 ;; and another for force-completion, maybe?). 2012 ;; and another for force-completion, maybe?).
2009 (overlay-put ol 'field 'completion)
2010 (overlay-put ol 'priority 100)
2011 (completion-in-region-mode 1) 2013 (completion-in-region-mode 1)
2012 (setq completion-in-region--data 2014 (setq completion-in-region--data
2013 (list start (copy-marker end) collection)) 2015 (list start (copy-marker end) collection))
2014 (unwind-protect 2016 (minibuffer-completion-help start end)))
2015 (call-interactively 'minibuffer-completion-help)
2016 (delete-overlay ol))))
2017 (`(,hookfun . ,_) 2017 (`(,hookfun . ,_)
2018 ;; The hook function already performed completion :-( 2018 ;; The hook function already performed completion :-(
2019 ;; Not much we can do at this point. 2019 ;; Not much we can do at this point.
@@ -2308,7 +2308,6 @@ the minibuffer empty.
2308For some commands, exiting with an empty minibuffer has a special meaning, 2308For some commands, exiting with an empty minibuffer has a special meaning,
2309such as making the current buffer visit no file in the case of 2309such as making the current buffer visit no file in the case of
2310`set-visited-file-name'." 2310`set-visited-file-name'."
2311 :group 'minibuffer
2312 :type 'boolean) 2311 :type 'boolean)
2313 2312
2314;; Not always defined, but only called if next-read-file-uses-dialog-p says so. 2313;; Not always defined, but only called if next-read-file-uses-dialog-p says so.
@@ -2701,7 +2700,6 @@ expression (not containing character ranges like `a-z')."
2701 ;; Refresh other vars. 2700 ;; Refresh other vars.
2702 (completion-pcm--prepare-delim-re value)) 2701 (completion-pcm--prepare-delim-re value))
2703 :initialize 'custom-initialize-reset 2702 :initialize 'custom-initialize-reset
2704 :group 'minibuffer
2705 :type 'string) 2703 :type 'string)
2706 2704
2707(defcustom completion-pcm-complete-word-inserts-delimiters nil 2705(defcustom completion-pcm-complete-word-inserts-delimiters nil
@@ -2734,7 +2732,8 @@ or a symbol, see `completion-pcm--merge-completions'."
2734 (completion-pcm--string->pattern suffix))) 2732 (completion-pcm--string->pattern suffix)))
2735 (let* ((pattern nil) 2733 (let* ((pattern nil)
2736 (p 0) 2734 (p 0)
2737 (p0 p)) 2735 (p0 p)
2736 (pending nil))
2738 2737
2739 (while (and (setq p (string-match completion-pcm--delim-wild-regex 2738 (while (and (setq p (string-match completion-pcm--delim-wild-regex
2740 string p)) 2739 string p))
@@ -2751,18 +2750,49 @@ or a symbol, see `completion-pcm--merge-completions'."
2751 ;; This is determined by the presence of a submatch-1 which delimits 2750 ;; This is determined by the presence of a submatch-1 which delimits
2752 ;; the prefix. 2751 ;; the prefix.
2753 (if (match-end 1) (setq p (match-end 1))) 2752 (if (match-end 1) (setq p (match-end 1)))
2754 (push (substring string p0 p) pattern) 2753 (unless (= p0 p)
2754 (if pending (push pending pattern))
2755 (push (substring string p0 p) pattern))
2756 (setq pending nil)
2755 (if (eq (aref string p) ?*) 2757 (if (eq (aref string p) ?*)
2756 (progn 2758 (progn
2757 (push 'star pattern) 2759 (push 'star pattern)
2758 (setq p0 (1+ p))) 2760 (setq p0 (1+ p)))
2759 (push 'any pattern) 2761 (push 'any pattern)
2760 (setq p0 p)) 2762 (if (match-end 1)
2761 (cl-incf p)) 2763 (setq p0 p)
2762 2764 (push (substring string p (match-end 0)) pattern)
2765 ;; `any-delim' is used so that "a-b" also finds "array->beginning".
2766 (setq pending 'any-delim)
2767 (setq p0 (match-end 0))))
2768 (setq p p0))
2769
2770 (when (> (length string) p0)
2771 (if pending (push pending pattern))
2772 (push (substring string p0) pattern))
2763 ;; An empty string might be erroneously added at the beginning. 2773 ;; An empty string might be erroneously added at the beginning.
2764 ;; It should be avoided properly, but it's so easy to remove it here. 2774 ;; It should be avoided properly, but it's so easy to remove it here.
2765 (delete "" (nreverse (cons (substring string p0) pattern)))))) 2775 (delete "" (nreverse pattern)))))
2776
2777(defun completion-pcm--optimize-pattern (p)
2778 ;; Remove empty strings in a separate phase since otherwise a ""
2779 ;; might prevent some other optimization, as in '(any "" any).
2780 (setq p (delete "" p))
2781 (let ((n '()))
2782 (while p
2783 (pcase p
2784 (`(,(and s1 (pred stringp)) ,(and s2 (pred stringp)) . ,rest)
2785 (setq p (cons (concat s1 s2) rest)))
2786 (`(,(and p1 (pred symbolp)) ,(and p2 (guard (eq p1 p2))) . ,_)
2787 (setq p (cdr p)))
2788 (`(star ,(pred symbolp) . ,rest) (setq p `(star . ,rest)))
2789 (`(,(pred symbolp) star . ,rest) (setq p `(star . ,rest)))
2790 (`(point ,(or `any `any-delim) . ,rest) (setq p `(point . ,rest)))
2791 (`(,(or `any `any-delim) point . ,rest) (setq p `(point . ,rest)))
2792 (`(any ,(or `any `any-delim) . ,rest) (setq p `(any . ,rest)))
2793 (`(,(pred symbolp)) (setq p nil)) ;Implicit terminating `any'.
2794 (_ (push (pop p) n))))
2795 (nreverse n)))
2766 2796
2767(defun completion-pcm--pattern->regex (pattern &optional group) 2797(defun completion-pcm--pattern->regex (pattern &optional group)
2768 (let ((re 2798 (let ((re
@@ -2771,8 +2801,13 @@ or a symbol, see `completion-pcm--merge-completions'."
2771 (lambda (x) 2801 (lambda (x)
2772 (cond 2802 (cond
2773 ((stringp x) (regexp-quote x)) 2803 ((stringp x) (regexp-quote x))
2774 ((if (consp group) (memq x group) group) "\\(.*?\\)") 2804 (t
2775 (t ".*?"))) 2805 (let ((re (if (eq x 'any-delim)
2806 (concat completion-pcm--delim-wild-regex "*?")
2807 ".*?")))
2808 (if (if (consp group) (memq x group) group)
2809 (concat "\\(" re "\\)")
2810 re)))))
2776 pattern 2811 pattern
2777 "")))) 2812 ""))))
2778 ;; Avoid pathological backtracking. 2813 ;; Avoid pathological backtracking.
@@ -2846,11 +2881,11 @@ filter out additional entries (because TABLE might not obey PRED)."
2846 (setq string (substring string (car bounds) (+ point (cdr bounds)))) 2881 (setq string (substring string (car bounds) (+ point (cdr bounds))))
2847 (let* ((relpoint (- point (car bounds))) 2882 (let* ((relpoint (- point (car bounds)))
2848 (pattern (completion-pcm--string->pattern string relpoint)) 2883 (pattern (completion-pcm--string->pattern string relpoint))
2849 (all (condition-case err 2884 (all (condition-case-unless-debug err
2850 (funcall filter 2885 (funcall filter
2851 (completion-pcm--all-completions 2886 (completion-pcm--all-completions
2852 prefix pattern table pred)) 2887 prefix pattern table pred))
2853 (error (unless firsterror (setq firsterror err)) nil)))) 2888 (error (setq firsterror err) nil))))
2854 (when (and (null all) 2889 (when (and (null all)
2855 (> (car bounds) 0) 2890 (> (car bounds) 0)
2856 (null (ignore-errors (try-completion prefix table pred)))) 2891 (null (ignore-errors (try-completion prefix table pred))))
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index e70400af820..a1ead96eaea 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1424,7 +1424,8 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
1424 (string-match "^/?\\([^/]+\\)" localname) 1424 (string-match "^/?\\([^/]+\\)" localname)
1425 (list (tramp-gvfs-mount-spec-entry "type" "smb-share") 1425 (list (tramp-gvfs-mount-spec-entry "type" "smb-share")
1426 (tramp-gvfs-mount-spec-entry "server" host) 1426 (tramp-gvfs-mount-spec-entry "server" host)
1427 (tramp-gvfs-mount-spec-entry "share" (match-string 1 localname)))) 1427 (tramp-gvfs-mount-spec-entry
1428 "share" (match-string 1 localname))))
1428 ((string-equal "obex" method) 1429 ((string-equal "obex" method)
1429 (list (tramp-gvfs-mount-spec-entry "type" method) 1430 (list (tramp-gvfs-mount-spec-entry "type" method)
1430 (tramp-gvfs-mount-spec-entry 1431 (tramp-gvfs-mount-spec-entry
@@ -1441,7 +1442,8 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
1441 ,@(when domain 1442 ,@(when domain
1442 (list (tramp-gvfs-mount-spec-entry "domain" domain))) 1443 (list (tramp-gvfs-mount-spec-entry "domain" domain)))
1443 ,@(when port 1444 ,@(when port
1444 (list (tramp-gvfs-mount-spec-entry "port" (number-to-string port)))))) 1445 (list (tramp-gvfs-mount-spec-entry
1446 "port" (number-to-string port))))))
1445 (mount-pref 1447 (mount-pref
1446 (if (and (string-match "\\`dav" method) 1448 (if (and (string-match "\\`dav" method)
1447 (string-match "^/?[^/]+" localname)) 1449 (string-match "^/?[^/]+" localname))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 6c3ae376dc3..727536b2e10 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -690,7 +690,7 @@ Useful for \"rsync\" like methods.")
690;; Tramp only knows how to deal with `file-name-handler-alist', not 690;; Tramp only knows how to deal with `file-name-handler-alist', not
691;; the other places. 691;; the other places.
692 692
693;; Currently, we have the choice between 'ftp, 'sep, and 'url. 693;; Currently, we have the choice between 'ftp and 'sep.
694;;;###autoload 694;;;###autoload
695(defcustom tramp-syntax 695(defcustom tramp-syntax
696 (if (featurep 'xemacs) 'sep 'ftp) 696 (if (featurep 'xemacs) 'sep 'ftp)
@@ -699,20 +699,15 @@ Useful for \"rsync\" like methods.")
699It can have the following values: 699It can have the following values:
700 700
701 'ftp -- Ange-FTP respective EFS like syntax (GNU Emacs default) 701 'ftp -- Ange-FTP respective EFS like syntax (GNU Emacs default)
702 'sep -- Syntax as defined for XEmacs (not available yet for GNU Emacs) 702 'sep -- Syntax as defined for XEmacs."
703 'url -- URL-like syntax."
704 :group 'tramp 703 :group 'tramp
705 :type (if (featurep 'xemacs) 704 :version "24.4"
706 '(choice (const :tag "EFS" ftp) 705 :type `(choice (const :tag ,(if (featurep 'xemacs) "EFS" "Ange-FTP") ftp)
707 (const :tag "XEmacs" sep) 706 (const :tag "XEmacs" sep)))
708 (const :tag "URL" url))
709 '(choice (const :tag "Ange-FTP" ftp)
710 (const :tag "URL" url))))
711 707
712(defconst tramp-prefix-format 708(defconst tramp-prefix-format
713 (cond ((equal tramp-syntax 'ftp) "/") 709 (cond ((equal tramp-syntax 'ftp) "/")
714 ((equal tramp-syntax 'sep) "/[") 710 ((equal tramp-syntax 'sep) "/[")
715 ((equal tramp-syntax 'url) "/")
716 (t (error "Wrong `tramp-syntax' defined"))) 711 (t (error "Wrong `tramp-syntax' defined")))
717 "String matching the very beginning of Tramp file names. 712 "String matching the very beginning of Tramp file names.
718Used in `tramp-make-tramp-file-name'.") 713Used in `tramp-make-tramp-file-name'.")
@@ -729,7 +724,6 @@ Should always start with \"^\". Derived from `tramp-prefix-format'.")
729(defconst tramp-postfix-method-format 724(defconst tramp-postfix-method-format
730 (cond ((equal tramp-syntax 'ftp) ":") 725 (cond ((equal tramp-syntax 'ftp) ":")
731 ((equal tramp-syntax 'sep) "/") 726 ((equal tramp-syntax 'sep) "/")
732 ((equal tramp-syntax 'url) "://")
733 (t (error "Wrong `tramp-syntax' defined"))) 727 (t (error "Wrong `tramp-syntax' defined")))
734 "String matching delimiter between method and user or host names. 728 "String matching delimiter between method and user or host names.
735Used in `tramp-make-tramp-file-name'.") 729Used in `tramp-make-tramp-file-name'.")
@@ -776,7 +770,6 @@ Derived from `tramp-postfix-user-format'.")
776(defconst tramp-prefix-ipv6-format 770(defconst tramp-prefix-ipv6-format
777 (cond ((equal tramp-syntax 'ftp) "[") 771 (cond ((equal tramp-syntax 'ftp) "[")
778 ((equal tramp-syntax 'sep) "") 772 ((equal tramp-syntax 'sep) "")
779 ((equal tramp-syntax 'url) "[")
780 (t (error "Wrong `tramp-syntax' defined"))) 773 (t (error "Wrong `tramp-syntax' defined")))
781 "String matching left hand side of IPv6 addresses. 774 "String matching left hand side of IPv6 addresses.
782Used in `tramp-make-tramp-file-name'.") 775Used in `tramp-make-tramp-file-name'.")
@@ -796,7 +789,6 @@ Derived from `tramp-prefix-ipv6-format'.")
796(defconst tramp-postfix-ipv6-format 789(defconst tramp-postfix-ipv6-format
797 (cond ((equal tramp-syntax 'ftp) "]") 790 (cond ((equal tramp-syntax 'ftp) "]")
798 ((equal tramp-syntax 'sep) "") 791 ((equal tramp-syntax 'sep) "")
799 ((equal tramp-syntax 'url) "]")
800 (t (error "Wrong `tramp-syntax' defined"))) 792 (t (error "Wrong `tramp-syntax' defined")))
801 "String matching right hand side of IPv6 addresses. 793 "String matching right hand side of IPv6 addresses.
802Used in `tramp-make-tramp-file-name'.") 794Used in `tramp-make-tramp-file-name'.")
@@ -809,7 +801,6 @@ Derived from `tramp-postfix-ipv6-format'.")
809(defconst tramp-prefix-port-format 801(defconst tramp-prefix-port-format
810 (cond ((equal tramp-syntax 'ftp) "#") 802 (cond ((equal tramp-syntax 'ftp) "#")
811 ((equal tramp-syntax 'sep) "#") 803 ((equal tramp-syntax 'sep) "#")
812 ((equal tramp-syntax 'url) ":")
813 (t (error "Wrong `tramp-syntax' defined"))) 804 (t (error "Wrong `tramp-syntax' defined")))
814 "String matching delimiter between host names and port numbers.") 805 "String matching delimiter between host names and port numbers.")
815 806
@@ -838,7 +829,6 @@ Derived from `tramp-postfix-hop-format'.")
838(defconst tramp-postfix-host-format 829(defconst tramp-postfix-host-format
839 (cond ((equal tramp-syntax 'ftp) ":") 830 (cond ((equal tramp-syntax 'ftp) ":")
840 ((equal tramp-syntax 'sep) "]") 831 ((equal tramp-syntax 'sep) "]")
841 ((equal tramp-syntax 'url) "")
842 (t (error "Wrong `tramp-syntax' defined"))) 832 (t (error "Wrong `tramp-syntax' defined")))
843 "String matching delimiter between host names and localnames. 833 "String matching delimiter between host names and localnames.
844Used in `tramp-make-tramp-file-name'.") 834Used in `tramp-make-tramp-file-name'.")
@@ -909,15 +899,9 @@ XEmacs uses a separate filename syntax for Tramp and EFS.
909See `tramp-file-name-structure' for more explanations.") 899See `tramp-file-name-structure' for more explanations.")
910 900
911;;;###autoload 901;;;###autoload
912(defconst tramp-file-name-regexp-url "\\`/[^/|:]+://"
913 "Value for `tramp-file-name-regexp' for URL-like remoting.
914See `tramp-file-name-structure' for more explanations.")
915
916;;;###autoload
917(defconst tramp-file-name-regexp 902(defconst tramp-file-name-regexp
918 (cond ((equal tramp-syntax 'ftp) tramp-file-name-regexp-unified) 903 (cond ((equal tramp-syntax 'ftp) tramp-file-name-regexp-unified)
919 ((equal tramp-syntax 'sep) tramp-file-name-regexp-separate) 904 ((equal tramp-syntax 'sep) tramp-file-name-regexp-separate)
920 ((equal tramp-syntax 'url) tramp-file-name-regexp-url)
921 (t (error "Wrong `tramp-syntax' defined"))) 905 (t (error "Wrong `tramp-syntax' defined")))
922 "Regular expression matching file names handled by Tramp. 906 "Regular expression matching file names handled by Tramp.
923This regexp should match Tramp file names but no other file names. 907This regexp should match Tramp file names but no other file names.
@@ -952,16 +936,9 @@ XEmacs uses a separate filename syntax for Tramp and EFS.
952See `tramp-file-name-structure' for more explanations.") 936See `tramp-file-name-structure' for more explanations.")
953 937
954;;;###autoload 938;;;###autoload
955(defconst tramp-completion-file-name-regexp-url
956 "\\`/[^/:]+\\(:\\(/\\(/[^/]*\\)?\\)?\\)?\\'"
957 "Value for `tramp-completion-file-name-regexp' for URL-like remoting.
958See `tramp-file-name-structure' for more explanations.")
959
960;;;###autoload
961(defconst tramp-completion-file-name-regexp 939(defconst tramp-completion-file-name-regexp
962 (cond ((equal tramp-syntax 'ftp) tramp-completion-file-name-regexp-unified) 940 (cond ((equal tramp-syntax 'ftp) tramp-completion-file-name-regexp-unified)
963 ((equal tramp-syntax 'sep) tramp-completion-file-name-regexp-separate) 941 ((equal tramp-syntax 'sep) tramp-completion-file-name-regexp-separate)
964 ((equal tramp-syntax 'url) tramp-completion-file-name-regexp-url)
965 (t (error "Wrong `tramp-syntax' defined"))) 942 (t (error "Wrong `tramp-syntax' defined")))
966 "Regular expression matching file names handled by Tramp completion. 943 "Regular expression matching file names handled by Tramp completion.
967This regexp should match partial Tramp file names only. 944This regexp should match partial Tramp file names only.
@@ -2542,64 +2519,40 @@ They are collected by `tramp-completion-dissect-file-name1'."
2542 tramp-prefix-ipv6-regexp 2519 tramp-prefix-ipv6-regexp
2543 "\\(" tramp-completion-ipv6-regexp x-nil "\\)$") 2520 "\\(" tramp-completion-ipv6-regexp x-nil "\\)$")
2544 nil 1 2 nil)) 2521 nil 1 2 nil))
2545 ;; "/method:user" "/[method/user" "/method://user" 2522 ;; "/method:user" "/[method/user"
2546 (tramp-completion-file-name-structure7 2523 (tramp-completion-file-name-structure7
2547 (list (concat tramp-prefix-regexp 2524 (list (concat tramp-prefix-regexp
2548 "\\(" tramp-method-regexp "\\)" tramp-postfix-method-regexp 2525 "\\(" tramp-method-regexp "\\)" tramp-postfix-method-regexp
2549 "\\(" tramp-user-regexp x-nil "\\)$") 2526 "\\(" tramp-user-regexp x-nil "\\)$")
2550 1 2 nil nil)) 2527 1 2 nil nil))
2551 ;; "/method:host" "/[method/host" "/method://host" 2528 ;; "/method:host" "/[method/host"
2552 (tramp-completion-file-name-structure8 2529 (tramp-completion-file-name-structure8
2553 (list (concat tramp-prefix-regexp 2530 (list (concat tramp-prefix-regexp
2554 "\\(" tramp-method-regexp "\\)" tramp-postfix-method-regexp 2531 "\\(" tramp-method-regexp "\\)" tramp-postfix-method-regexp
2555 "\\(" tramp-host-regexp x-nil "\\)$") 2532 "\\(" tramp-host-regexp x-nil "\\)$")
2556 1 nil 2 nil)) 2533 1 nil 2 nil))
2557 ;; "/method:[ipv6" "/[method/ipv6" "/method://[ipv6" 2534 ;; "/method:[ipv6" "/[method/ipv6"
2558 (tramp-completion-file-name-structure9 2535 (tramp-completion-file-name-structure9
2559 (list (concat tramp-prefix-regexp 2536 (list (concat tramp-prefix-regexp
2560 "\\(" tramp-method-regexp "\\)" tramp-postfix-method-regexp 2537 "\\(" tramp-method-regexp "\\)" tramp-postfix-method-regexp
2561 tramp-prefix-ipv6-regexp 2538 tramp-prefix-ipv6-regexp
2562 "\\(" tramp-completion-ipv6-regexp x-nil "\\)$") 2539 "\\(" tramp-completion-ipv6-regexp x-nil "\\)$")
2563 1 nil 2 nil)) 2540 1 nil 2 nil))
2564 ;; "/method:user@host" "/[method/user@host" "/method://user@host" 2541 ;; "/method:user@host" "/[method/user@host"
2565 (tramp-completion-file-name-structure10 2542 (tramp-completion-file-name-structure10
2566 (list (concat tramp-prefix-regexp 2543 (list (concat tramp-prefix-regexp
2567 "\\(" tramp-method-regexp "\\)" tramp-postfix-method-regexp 2544 "\\(" tramp-method-regexp "\\)" tramp-postfix-method-regexp
2568 "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp 2545 "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp
2569 "\\(" tramp-host-regexp x-nil "\\)$") 2546 "\\(" tramp-host-regexp x-nil "\\)$")
2570 1 2 3 nil)) 2547 1 2 3 nil))
2571 ;; "/method:user@[ipv6" "/[method/user@ipv6" "/method://user@[ipv6" 2548 ;; "/method:user@[ipv6" "/[method/user@ipv6"
2572 (tramp-completion-file-name-structure11 2549 (tramp-completion-file-name-structure11
2573 (list (concat tramp-prefix-regexp 2550 (list (concat tramp-prefix-regexp
2574 "\\(" tramp-method-regexp "\\)" tramp-postfix-method-regexp 2551 "\\(" tramp-method-regexp "\\)" tramp-postfix-method-regexp
2575 "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp 2552 "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp
2576 tramp-prefix-ipv6-regexp 2553 tramp-prefix-ipv6-regexp
2577 "\\(" tramp-completion-ipv6-regexp x-nil "\\)$") 2554 "\\(" tramp-completion-ipv6-regexp x-nil "\\)$")
2578 1 2 3 nil)) 2555 1 2 3 nil)))
2579 ;; "/method: "/method:/"
2580 (tramp-completion-file-name-structure12
2581 (list
2582 (if (equal tramp-syntax 'url)
2583 (concat tramp-prefix-regexp
2584 "\\(" tramp-method-regexp "\\)"
2585 "\\(" (substring tramp-postfix-method-regexp 0 1)
2586 "\\|" (substring tramp-postfix-method-regexp 1 2) "\\)"
2587 "\\(" "\\)$")
2588 ;; Should not match if not URL syntax.
2589 (concat tramp-prefix-regexp "/$"))
2590 1 3 nil nil))
2591 ;; "/method: "/method:/"
2592 (tramp-completion-file-name-structure13
2593 (list
2594 (if (equal tramp-syntax 'url)
2595 (concat tramp-prefix-regexp
2596 "\\(" tramp-method-regexp "\\)"
2597 "\\(" (substring tramp-postfix-method-regexp 0 1)
2598 "\\|" (substring tramp-postfix-method-regexp 1 2) "\\)"
2599 "\\(" "\\)$")
2600 ;; Should not match if not URL syntax.
2601 (concat tramp-prefix-regexp "/$"))
2602 1 nil 3 nil)))
2603 2556
2604 (mapc (lambda (structure) 2557 (mapc (lambda (structure)
2605 (add-to-list 'result 2558 (add-to-list 'result
@@ -2616,8 +2569,6 @@ They are collected by `tramp-completion-dissect-file-name1'."
2616 tramp-completion-file-name-structure9 2569 tramp-completion-file-name-structure9
2617 tramp-completion-file-name-structure10 2570 tramp-completion-file-name-structure10
2618 tramp-completion-file-name-structure11 2571 tramp-completion-file-name-structure11
2619 tramp-completion-file-name-structure12
2620 tramp-completion-file-name-structure13
2621 tramp-file-name-structure)) 2572 tramp-file-name-structure))
2622 2573
2623 (delq nil result))) 2574 (delq nil result)))
@@ -3289,35 +3240,19 @@ User is always nil."
3289 3240
3290(defun tramp-handle-substitute-in-file-name (filename) 3241(defun tramp-handle-substitute-in-file-name (filename)
3291 "Like `substitute-in-file-name' for Tramp files. 3242 "Like `substitute-in-file-name' for Tramp files.
3292\"//\" and \"/~\" substitute only in the local filename part. 3243\"//\" and \"/~\" substitute only in the local filename part."
3293If the URL Tramp syntax is chosen, \"//\" as method delimiter and \"/~\" at
3294beginning of local filename are not substituted."
3295 ;; First, we must replace environment variables. 3244 ;; First, we must replace environment variables.
3296 (setq filename (tramp-replace-environment-variables filename)) 3245 (setq filename (tramp-replace-environment-variables filename))
3297 (with-parsed-tramp-file-name filename nil 3246 (with-parsed-tramp-file-name filename nil
3298 (if (equal tramp-syntax 'url) 3247 ;; Ignore in LOCALNAME everything before "//" or "/~".
3299 ;; We need to check localname only. The other parts cannot contain 3248 (when (and (stringp localname) (string-match ".+?/\\(/\\|~\\)" localname))
3300 ;; "//" or "/~". 3249 (setq filename
3301 (if (and (> (length localname) 1) 3250 (concat (file-remote-p filename)
3302 (or (string-match "//" localname) 3251 (replace-match "\\1" nil nil localname)))
3303 (string-match "/~" localname 1))) 3252 ;; "/m:h:~" does not work for completion. We use "/m:h:~/".
3304 (tramp-run-real-handler 'substitute-in-file-name (list filename)) 3253 (when (string-match "~$" filename)
3305 (tramp-make-tramp-file-name 3254 (setq filename (concat filename "/"))))
3306 (when method (substitute-in-file-name method)) 3255 (tramp-run-real-handler 'substitute-in-file-name (list filename))))
3307 (when user (substitute-in-file-name user))
3308 (when host (substitute-in-file-name host))
3309 (when localname
3310 (tramp-run-real-handler
3311 'substitute-in-file-name (list localname)))))
3312 ;; Ignore in LOCALNAME everything before "//" or "/~".
3313 (when (and (stringp localname) (string-match ".+?/\\(/\\|~\\)" localname))
3314 (setq filename
3315 (concat (file-remote-p filename)
3316 (replace-match "\\1" nil nil localname)))
3317 ;; "/m:h:~" does not work for completion. We use "/m:h:~/".
3318 (when (string-match "~$" filename)
3319 (setq filename (concat filename "/"))))
3320 (tramp-run-real-handler 'substitute-in-file-name (list filename)))))
3321 3256
3322(defun tramp-handle-unhandled-file-name-directory (_filename) 3257(defun tramp-handle-unhandled-file-name-directory (_filename)
3323 "Like `unhandled-file-name-directory' for Tramp files." 3258 "Like `unhandled-file-name-directory' for Tramp files."
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index db2a6c68539..c8a9c461a9d 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -6905,32 +6905,38 @@ comment at the start of cc-engine.el for more info."
6905 6905
6906 ;; Skip over type decl prefix operators. (Note similar code in 6906 ;; Skip over type decl prefix operators. (Note similar code in
6907 ;; `c-font-lock-declarators'.) 6907 ;; `c-font-lock-declarators'.)
6908 (while (and (looking-at c-type-decl-prefix-key) 6908 (if (and c-recognize-typeless-decls
6909 (if (and (c-major-mode-is 'c++-mode) 6909 (equal c-type-decl-prefix-key "\\<\\>"))
6910 (match-beginning 3)) 6910 (when (eq (char-after) ?\()
6911 ;; If the third submatch matches in C++ then
6912 ;; we're looking at an identifier that's a
6913 ;; prefix only if it specifies a member pointer.
6914 (when (setq got-identifier (c-forward-name))
6915 (if (looking-at "\\(::\\)")
6916 ;; We only check for a trailing "::" and
6917 ;; let the "*" that should follow be
6918 ;; matched in the next round.
6919 (progn (setq got-identifier nil) t)
6920 ;; It turned out to be the real identifier,
6921 ;; so stop.
6922 nil))
6923 t))
6924
6925 (if (eq (char-after) ?\()
6926 (progn 6911 (progn
6927 (setq paren-depth (1+ paren-depth)) 6912 (setq paren-depth (1+ paren-depth))
6928 (forward-char)) 6913 (forward-char)))
6929 (unless got-prefix-before-parens 6914 (while (and (looking-at c-type-decl-prefix-key)
6930 (setq got-prefix-before-parens (= paren-depth 0))) 6915 (if (and (c-major-mode-is 'c++-mode)
6931 (setq got-prefix t) 6916 (match-beginning 3))
6932 (goto-char (match-end 1))) 6917 ;; If the third submatch matches in C++ then
6933 (c-forward-syntactic-ws)) 6918 ;; we're looking at an identifier that's a
6919 ;; prefix only if it specifies a member pointer.
6920 (when (setq got-identifier (c-forward-name))
6921 (if (looking-at "\\(::\\)")
6922 ;; We only check for a trailing "::" and
6923 ;; let the "*" that should follow be
6924 ;; matched in the next round.
6925 (progn (setq got-identifier nil) t)
6926 ;; It turned out to be the real identifier,
6927 ;; so stop.
6928 nil))
6929 t))
6930
6931 (if (eq (char-after) ?\()
6932 (progn
6933 (setq paren-depth (1+ paren-depth))
6934 (forward-char))
6935 (unless got-prefix-before-parens
6936 (setq got-prefix-before-parens (= paren-depth 0)))
6937 (setq got-prefix t)
6938 (goto-char (match-end 1)))
6939 (c-forward-syntactic-ws)))
6934 6940
6935 (setq got-parens (> paren-depth 0)) 6941 (setq got-parens (> paren-depth 0))
6936 6942
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 0116e9ec3dd..80e6189822b 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -2816,7 +2816,8 @@ is in effect when this is matched (see `c-identifier-syntax-table')."
2816 "\\>") 2816 "\\>")
2817 "") 2817 "")
2818 "\\)") 2818 "\\)")
2819 (java idl) "\\([\[\(]\\)") 2819 java "\\([\[\(\)]\\)"
2820 idl "\\([\[\(]\\)")
2820(c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key) 2821(c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key)
2821 'dont-doc) 2822 'dont-doc)
2822 2823
@@ -2937,7 +2938,7 @@ calls before a brace block. This setting does not affect declarations
2937that are preceded by a declaration starting keyword, so 2938that are preceded by a declaration starting keyword, so
2938e.g. `c-typeless-decl-kwds' may still be used when it's set to nil." 2939e.g. `c-typeless-decl-kwds' may still be used when it's set to nil."
2939 t nil 2940 t nil
2940 (c c++ objc) t) 2941 (c c++ objc java) t)
2941(c-lang-defvar c-recognize-typeless-decls 2942(c-lang-defvar c-recognize-typeless-decls
2942 (c-lang-const c-recognize-typeless-decls)) 2943 (c-lang-const c-recognize-typeless-decls))
2943 2944
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index acc7738ae5c..0f868255589 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -1862,11 +1862,11 @@ See `font-lock-syntax-table'.")
1862 "using") 1862 "using")
1863 'symbols)) 1863 'symbols))
1864 1 'font-lock-builtin-face) 1864 1 'font-lock-builtin-face)
1865 ;; Perl-ish keywords
1866 "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$"
1867 ;; here-doc beginnings 1865 ;; here-doc beginnings
1868 `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0)) 1866 `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0))
1869 'font-lock-string-face)) 1867 'font-lock-string-face))
1868 ;; Perl-ish keywords
1869 "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$"
1870 ;; variables 1870 ;; variables
1871 `(,(concat ruby-font-lock-keyword-beg-re 1871 `(,(concat ruby-font-lock-keyword-beg-re
1872 "\\_<\\(nil\\|self\\|true\\|false\\)\\>") 1872 "\\_<\\(nil\\|self\\|true\\|false\\)\\>")
diff --git a/lisp/replace.el b/lisp/replace.el
index 5e44677b0f8..abb59a674e3 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -490,12 +490,13 @@ If `replace-lax-whitespace' is non-nil, a space or spaces in the string
490to be replaced will match a sequence of whitespace chars defined by the 490to be replaced will match a sequence of whitespace chars defined by the
491regexp in `search-whitespace-regexp'. 491regexp in `search-whitespace-regexp'.
492 492
493In Transient Mark mode, if the mark is active, operate on the contents
494of the region. Otherwise, operate from point to the end of the buffer.
495
496Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace 493Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
497only matches surrounded by word boundaries. 494only matches surrounded by word boundaries.
498Fourth and fifth arg START and END specify the region to operate on. 495
496Operates on the region between START and END (if both are nil, from point
497to the end of the buffer). Interactively, if Transient Mark mode is
498enabled and the mark is active, operates on the contents of the region;
499otherwise from point to the end of the buffer.
499 500
500Use \\<minibuffer-local-map>\\[next-history-element] \ 501Use \\<minibuffer-local-map>\\[next-history-element] \
501to pull the last incremental search string to the minibuffer 502to pull the last incremental search string to the minibuffer
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 171f373317a..795c04e31e1 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -468,7 +468,7 @@ alternatives, starting from zero."
468 nil 468 nil
469 (("editor") ("editora") ("editorb") ("editorc") 469 (("editor") ("editora") ("editorb") ("editorc")
470 ("translator") ("annotator") ("commentator") 470 ("translator") ("annotator") ("commentator")
471 ("introduction") ("foreword") ("afterword") ("titleaddon") 471 ("introduction") ("foreword") ("afterword") ("subtitle") ("titleaddon")
472 ("maintitle") ("mainsubtitle") ("maintitleaddon") 472 ("maintitle") ("mainsubtitle") ("maintitleaddon")
473 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") 473 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
474 ("series") ("number") ("note") ("publisher") ("location") ("isbn") 474 ("series") ("number") ("note") ("publisher") ("location") ("isbn")