aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2013-02-12 00:04:05 +0100
committerJoakim Verona2013-02-12 00:04:05 +0100
commite0444a0966fa001953bb97cfb60451c42220be8e (patch)
treed5d10a2f99fa0c7b24eee310069e2677409e6802
parent77f4834db1299b571b1fb3dfb120e5e50eec7cb1 (diff)
parent6659b59ccb7909a07f71a0143fd9d85e60b8e414 (diff)
downloademacs-e0444a0966fa001953bb97cfb60451c42220be8e.tar.gz
emacs-e0444a0966fa001953bb97cfb60451c42220be8e.zip
auto upstream
-rw-r--r--ChangeLog4
-rwxr-xr-xautogen/configure12
-rw-r--r--configure.ac12
-rw-r--r--etc/ChangeLog4
-rw-r--r--etc/NEWS43
-rw-r--r--etc/PROBLEMS33
-rw-r--r--lisp/ChangeLog27
-rw-r--r--lisp/cus-start.el19
-rw-r--r--lisp/doc-view.el3
-rw-r--r--lisp/erc/erc-match.el20
-rw-r--r--lisp/files.el11
-rw-r--r--lisp/net/ange-ftp.el2
-rw-r--r--lisp/tutorial.el10
-rw-r--r--lisp/vc/diff.el25
-rw-r--r--lisp/vc/vc-svn.el29
-rw-r--r--src/ChangeLog76
-rw-r--r--src/cm.c3
-rw-r--r--src/fileio.c5
-rw-r--r--src/keyboard.c472
-rw-r--r--src/keyboard.h2
-rw-r--r--src/keymap.c6
-rw-r--r--src/lread.c6
-rw-r--r--src/marker.c28
-rw-r--r--src/window.c20
-rw-r--r--src/xdisp.c16
25 files changed, 370 insertions, 518 deletions
diff --git a/ChangeLog b/ChangeLog
index f1b134aa8f3..9cb50f67d7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
12013-02-11 Glenn Morris <rgm@gnu.org>
2
3 * configure.ac (emacs_config_options): Record some env vars.
4
12013-02-10 Glenn Morris <rgm@gnu.org> 52013-02-10 Glenn Morris <rgm@gnu.org>
2 6
3 * configure.ac (emacs_config_options): Strip out the (internal) 7 * configure.ac (emacs_config_options): Strip out the (internal)
diff --git a/autogen/configure b/autogen/configure
index 1251680b942..8226d489f72 100755
--- a/autogen/configure
+++ b/autogen/configure
@@ -3367,7 +3367,19 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
3367ac_compiler_gnu=$ac_cv_c_compiler_gnu 3367ac_compiler_gnu=$ac_cv_c_compiler_gnu
3368 3368
3369 3369
3370
3370emacs_config_options="$@" 3371emacs_config_options="$@"
3372## Add some environment variables, if they were passed via the environment
3373## rather than on the command-line.
3374for var in CFLAGS CPPFLAGS LDFLAGS; do
3375 case "$emacs_config_options" in
3376 *$var=*) continue ;;
3377 esac
3378 eval val="\$${var}"
3379 test x"$val" = x && continue
3380 emacs_config_options="${emacs_config_options}${emacs_config_options:+ }$var=$val"
3381done
3382
3371ac_config_headers="$ac_config_headers src/config.h:src/config.in" 3383ac_config_headers="$ac_config_headers src/config.h:src/config.in"
3372 3384
3373 3385
diff --git a/configure.ac b/configure.ac
index 7d79db32568..8dfc5c9ba47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,9 +23,21 @@ dnl along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 23
24AC_PREREQ(2.65) 24AC_PREREQ(2.65)
25AC_INIT(emacs, 24.3.50) 25AC_INIT(emacs, 24.3.50)
26
26dnl This is the documented way to record the args passed to configure, 27dnl This is the documented way to record the args passed to configure,
27dnl rather than $ac_configure_args. 28dnl rather than $ac_configure_args.
28emacs_config_options="$@" 29emacs_config_options="$@"
30## Add some environment variables, if they were passed via the environment
31## rather than on the command-line.
32for var in CFLAGS CPPFLAGS LDFLAGS; do
33 case "$emacs_config_options" in
34 *$var=*) continue ;;
35 esac
36 eval val="\$${var}"
37 test x"$val" = x && continue
38 emacs_config_options="${emacs_config_options}${emacs_config_options:+ }$var=$val"
39done
40
29AC_CONFIG_HEADER(src/config.h:src/config.in) 41AC_CONFIG_HEADER(src/config.h:src/config.in)
30AC_CONFIG_SRCDIR(src/lisp.h) 42AC_CONFIG_SRCDIR(src/lisp.h)
31AC_CONFIG_AUX_DIR(build-aux) 43AC_CONFIG_AUX_DIR(build-aux)
diff --git a/etc/ChangeLog b/etc/ChangeLog
index f6f47d6d1a8..d1b5aac955d 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
12013-02-11 Michael Albinus <michael.albinus@gmx.de>
2
3 * NEWS: Add autorevert changes.
4
12013-02-05 Jan Djärv <jan.h.d@swipnet.se> 52013-02-05 Jan Djärv <jan.h.d@swipnet.se>
2 6
3 * NEWS: Mention ns-use-native-fullscreen. 7 * NEWS: Mention ns-use-native-fullscreen.
diff --git a/etc/NEWS b/etc/NEWS
index 91ebe803904..a29c8eb054e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -28,7 +28,10 @@ This happens by default if a suitable support library is found at
28build time, like libacl on GNU/Linux. To prevent this, use the 28build time, like libacl on GNU/Linux. To prevent this, use the
29configure option `--without-acl'. 29configure option `--without-acl'.
30 30
31
31* Startup Changes in Emacs 24.4 32* Startup Changes in Emacs 24.4
33
34
32* Changes in Emacs 24.4 35* Changes in Emacs 24.4
33 36
34+++ 37+++
@@ -42,6 +45,10 @@ non-nil, they output the same results.
42** `eval-defun' on an already defined defcustom calls the :set function, 45** `eval-defun' on an already defined defcustom calls the :set function,
43if there is one. 46if there is one.
44 47
48** If the new variable `enable-dir-local-variables' is nil,
49directory local variables are ignored. May be useful for some modes
50that want to ignore directory-locals while still respecting file-locals.
51
45** The option `set-mark-default-inactive' has been deleted. 52** The option `set-mark-default-inactive' has been deleted.
46This unfinished feature was introduced by accident in Emacs 23.1; 53This unfinished feature was introduced by accident in Emacs 23.1;
47simply disabling Transient Mark mode does the same thing. 54simply disabling Transient Mark mode does the same thing.
@@ -63,13 +70,7 @@ Available only on X, this option allows to control over-scrolling
63using the scroll bar (i.e. dragging the thumb down even when the end 70using the scroll bar (i.e. dragging the thumb down even when the end
64of the buffer is visible). 71of the buffer is visible).
65 72
66** Nextstep (GNUstep / Mac OS X) port 73
67
68*** Improved fullscreen support.
69Both native (>= OSX 10.7) and "old style" fullscreen are supported.
70Customize ns-use-native-fullscreen to change style. For >= 10.7
71native is the default.
72
73* Editing Changes in Emacs 24.4 74* Editing Changes in Emacs 24.4
74 75
75** New commands `toggle-frame-fullscreen' and `toggle-frame-maximized', 76** New commands `toggle-frame-fullscreen' and `toggle-frame-maximized',
@@ -206,8 +207,11 @@ It is layered as:
206- advice-add/advice-remove to add/remove a piece of advice on a named function, 207- advice-add/advice-remove to add/remove a piece of advice on a named function,
207 much like `defadvice' does. 208 much like `defadvice' does.
208 209
210
209* Incompatible Lisp Changes in Emacs 24.4 211* Incompatible Lisp Changes in Emacs 24.4
210 212
213** Removed inhibit-local-menu-bar-menus.
214
211** frame-local variables that affect redisplay do not work any more. 215** frame-local variables that affect redisplay do not work any more.
212More specifically, the redisplay does not bother to check for a frame-local 216More specifically, the redisplay does not bother to check for a frame-local
213value when looking up variables. 217value when looking up variables.
@@ -229,7 +233,8 @@ alist of extended attributes as returned by the new function
229`file-extended-attributes'. The attributes can be applied to another 233`file-extended-attributes'. The attributes can be applied to another
230file using `set-file-extended-attributes'. 234file using `set-file-extended-attributes'.
231 235
232* Lisp changes in Emacs 24.4 236
237* Lisp Changes in Emacs 24.4
233 238
234** Support for filesystem notifications. 239** Support for filesystem notifications.
235Emacs now supports notifications of filesystem changes, such as 240Emacs now supports notifications of filesystem changes, such as
@@ -237,6 +242,20 @@ creation, modification, and deletion of files. This requires the
237'inotify' API on GNU/Linux systems. On MS-Windows systems, this is 242'inotify' API on GNU/Linux systems. On MS-Windows systems, this is
238supported for Windows XP and newer versions. 243supported for Windows XP and newer versions.
239 244
245** Changes in autorevert.el
246
247---
248*** If Emacs is compiled with file notification support, notifications
249are used instead of checking the time stamp of the files. You can
250disable this by setting the user option `auto-revert-use-notify' to
251nil. Alternatively, a regular expression of directories to be
252excluded from file notifications can be specified by
253`auto-revert-notify-exclude-dir-regexp'.
254
255---
256*** The new user option `auto-revert-remote-files' enables reversion
257of remote files when set to non-nil.
258
240** Face changes 259** Face changes
241 260
242*** The `face-spec-set' is now analogous to `setq' for face specs. 261*** The `face-spec-set' is now analogous to `setq' for face specs.
@@ -273,7 +292,8 @@ used in place of the 9th element of `file-attributes'.
273`preserve-extended-attributes' as it now handles both SELinux context 292`preserve-extended-attributes' as it now handles both SELinux context
274and ACL entries. 293and ACL entries.
275 294
276* Changes in Emacs 24.4 on non-free operating systems 295
296* Changes in Emacs 24.4 on Non-Free Operating Systems
277 297
278+++ 298+++
279** The "generate a backtrace on fatal error" feature now works on MS Windows. 299** The "generate a backtrace on fatal error" feature now works on MS Windows.
@@ -286,6 +306,11 @@ Setting it has no effect, and %t in the mode-line format is ignored.
286Likewise, `file-name-buffer-file-type-alist' is now obsolete, and 306Likewise, `file-name-buffer-file-type-alist' is now obsolete, and
287modifying it has no effect. 307modifying it has no effect.
288 308
309** Improved fullscreen support on Mac OS X.
310Both native (>= OSX 10.7) and "old style" fullscreen are supported.
311Customize `ns-use-native-fullscreen' to change style. For >= 10.7
312native is the default.
313
289 314
290* Installation Changes in Emacs 24.3 315* Installation Changes in Emacs 24.3
291 316
diff --git a/etc/PROBLEMS b/etc/PROBLEMS
index 2a588c159c9..441ad7b4df4 100644
--- a/etc/PROBLEMS
+++ b/etc/PROBLEMS
@@ -3198,39 +3198,6 @@ floating point option: -fsoft.
3198 3198
3199This seems to be due to a GCC bug; it is fixed in GCC 2.8.1. 3199This seems to be due to a GCC bug; it is fixed in GCC 2.8.1.
3200 3200
3201** Vax C compiler bugs affecting Emacs.
3202
3203You may get one of these problems compiling Emacs:
3204
3205 foo.c line nnn: compiler error: no table entry for op STASG
3206 foo.c: fatal error in /lib/ccom
3207
3208These are due to bugs in the C compiler; the code is valid C.
3209Unfortunately, the bugs are unpredictable: the same construct
3210may compile properly or trigger one of these bugs, depending
3211on what else is in the source file being compiled. Even changes
3212in header files that should not affect the file being compiled
3213can affect whether the bug happens. In addition, sometimes files
3214that compile correctly on one machine get this bug on another machine.
3215
3216As a result, it is hard for me to make sure this bug will not affect
3217you. I have attempted to find and alter these constructs, but more
3218can always appear. However, I can tell you how to deal with it if it
3219should happen. The bug comes from having an indexed reference to an
3220array of Lisp_Objects, as an argument in a function call:
3221 Lisp_Object *args;
3222 ...
3223 ... foo (5, args[i], ...)...
3224putting the argument into a temporary variable first, as in
3225 Lisp_Object *args;
3226 Lisp_Object tem;
3227 ...
3228 tem = args[i];
3229 ... foo (r, tem, ...)...
3230causes the problem to go away.
3231The `contents' field of a Lisp vector is an array of Lisp_Objects,
3232so you may see the problem happening with indexed references to that.
3233
3234 3201
3235This file is part of GNU Emacs. 3202This file is part of GNU Emacs.
3236 3203
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2878db6271f..fd2186fcfb2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,7 +1,30 @@
12013-02-11 Elias Pipping <pipping@lavabit.com>
2
3 * doc-view.el (doc-view-current-cache-dir): Beware % escapes
4 (bug#13689).
5
62013-02-11 Stefan Monnier <monnier@iro.umontreal.ca>
7
8 * cus-start.el (all): Remove inhibit-local-menu-bar-menus.
9
102013-02-11 Glenn Morris <rgm@gnu.org>
11
12 * vc/diff.el (diff-use-labels): New variable.
13 (diff-no-select): Use --label rather than -L, and first
14 check that it is supported. (Bug#11067)
15
16 * files.el (enable-dir-local-variables): New variable.
17 (hack-dir-local-variables): Respect enable-dir-local-variables.
18 * tutorial.el (help-with-tutorial):
19 Ignore directory-local variables. (Bug#11127)
20
21 * vc/vc-svn.el (vc-svn-command): Move --non-interactive from here...
22 (vc-svn-global-switches): ... to here. (Bug#13513)
23
12013-02-10 Christopher Schmidt <christopher@ch.ristopher.com> 242013-02-10 Christopher Schmidt <christopher@ch.ristopher.com>
2 25
3 * minibuf-eldef.el (minibuffer-default--in-prompt-regexps): Handle 26 * minibuf-eldef.el (minibuffer-default--in-prompt-regexps):
4 "foo (bar, default: xxx): " prompts. 27 Handle "foo (bar, default: xxx): " prompts.
5 28
62013-02-10 Chong Yidong <cyd@gnu.org> 292013-02-10 Chong Yidong <cyd@gnu.org>
7 30
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 2bc47426332..2e442b6c944 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -286,7 +286,6 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
286 (double-click-time mouse (restricted-sexp 286 (double-click-time mouse (restricted-sexp
287 :match-alternatives (integerp 'nil 't))) 287 :match-alternatives (integerp 'nil 't)))
288 (double-click-fuzz mouse integer "22.1") 288 (double-click-fuzz mouse integer "22.1")
289 (inhibit-local-menu-bar-menus menu boolean)
290 (help-char keyboard character) 289 (help-char keyboard character)
291 (help-event-list keyboard (repeat (sexp :format "%v"))) 290 (help-event-list keyboard (repeat (sexp :format "%v")))
292 (menu-prompting menu boolean) 291 (menu-prompting menu boolean)
@@ -301,15 +300,15 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
301 (const :tag "When sent SIGUSR2" sigusr2)) 300 (const :tag "When sent SIGUSR2" sigusr2))
302 "24.1") 301 "24.1")
303 302
304;; This is not good news because it will use the wrong 303 ;; This is not good news because it will use the wrong
305;; version-specific directories when you upgrade. We need 304 ;; version-specific directories when you upgrade. We need
306;; customization of the front of the list, maintaining the standard 305 ;; customization of the front of the list, maintaining the
307;; value intact at the back. 306 ;; standard value intact at the back.
308;;; (load-path environment 307 ;;(load-path environment
309;;; (repeat (choice :tag "[Current dir?]" 308 ;; (repeat (choice :tag "[Current dir?]"
310;;; :format "%[Current dir?%] %v" 309 ;; :format "%[Current dir?%] %v"
311;;; (const :tag " current dir" nil) 310 ;; (const :tag " current dir" nil)
312;;; (directory :format "%v")))) 311 ;; (directory :format "%v"))))
313 ;; minibuf.c 312 ;; minibuf.c
314 (enable-recursive-minibuffers minibuffer boolean) 313 (enable-recursive-minibuffers minibuffer boolean)
315 (history-length minibuffer 314 (history-length minibuffer
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index e7d1ebc35ff..edd59a7b518 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -686,7 +686,8 @@ It's a subdirectory of `doc-view-cache-directory'."
686 (setq doc-view-current-cache-dir 686 (setq doc-view-current-cache-dir
687 (file-name-as-directory 687 (file-name-as-directory
688 (expand-file-name 688 (expand-file-name
689 (concat (file-name-nondirectory doc-view-buffer-file-name) 689 (concat (subst-char-in-string ?% ?_ ;; bug#13679
690 (file-name-nondirectory doc-view-buffer-file-name))
690 "-" 691 "-"
691 (let ((file doc-view-buffer-file-name)) 692 (let ((file doc-view-buffer-file-name))
692 (with-temp-buffer 693 (with-temp-buffer
diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el
index 7ca86b5ac95..1da838557f7 100644
--- a/lisp/erc/erc-match.el
+++ b/lisp/erc/erc-match.el
@@ -447,16 +447,24 @@ Use this defun with `erc-insert-modify-hook'."
447 (nth 0 (erc-parse-user nickuserhost)))) 447 (nth 0 (erc-parse-user nickuserhost))))
448 (old-pt (point)) 448 (old-pt (point))
449 (nick-beg (and nickname 449 (nick-beg (and nickname
450 (re-search-forward (regexp-quote nickname) 450 (re-search-forward "\\(\\* \\)?"(regexp-quote nickname)
451 (point-max) t) 451 (point-max) t)
452 (match-beginning 0))) 452 (match-beginning 0)))
453 (nick-end (when nick-beg 453 (nick-end (when nick-beg
454 (match-end 0))) 454 (match-end 0)))
455 (message (buffer-substring (if (and nick-end 455 (message (buffer-substring
456 (<= (+ 2 nick-end) (point-max))) 456 (if (and nick-end
457 (+ 2 nick-end) 457 (<= (+ 2 nick-end) (point-max)))
458 (point-min)) 458 (+ nick-end
459 (point-max)))) 459 ;; Message starts 2 characters after the nick except
460 ;; for CTCP ACTION messages.
461 (if (string= "* "
462 (buffer-substring (- nick-beg 2)
463 nick-beg))
464 1
465 2))
466 (point-min))
467 (point-max))))
460 (when (and vector 468 (when (and vector
461 (not (and erc-match-exclude-server-buffer 469 (not (and erc-match-exclude-server-buffer
462 (erc-server-buffer-p)))) 470 (erc-server-buffer-p))))
diff --git a/lisp/files.el b/lisp/files.el
index c9e5d2763fe..890834d4af0 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -507,6 +507,11 @@ and ignores this variable."
507 (other :tag "Query" other)) 507 (other :tag "Query" other))
508 :group 'find-file) 508 :group 'find-file)
509 509
510(defvar enable-dir-local-variables t
511 "Non-nil means enable use of directory-local variables.
512Some modes may wish to set this to nil to prevent directory-local
513settings being applied, but still respect file-local ones.")
514
510;; This is an odd variable IMO. 515;; This is an odd variable IMO.
511;; You might wonder why it is needed, when we could just do: 516;; You might wonder why it is needed, when we could just do:
512;; (set (make-local-variable 'enable-local-variables) nil) 517;; (set (make-local-variable 'enable-local-variables) nil)
@@ -3659,8 +3664,12 @@ is found. Returns the new class name."
3659(defun hack-dir-local-variables () 3664(defun hack-dir-local-variables ()
3660 "Read per-directory local variables for the current buffer. 3665 "Read per-directory local variables for the current buffer.
3661Store the directory-local variables in `dir-local-variables-alist' 3666Store the directory-local variables in `dir-local-variables-alist'
3662and `file-local-variables-alist', without applying them." 3667and `file-local-variables-alist', without applying them.
3668
3669This does nothing if either `enable-local-variables' or
3670`enable-dir-local-variables' are nil."
3663 (when (and enable-local-variables 3671 (when (and enable-local-variables
3672 enable-dir-local-variables
3664 (or enable-remote-dir-locals 3673 (or enable-remote-dir-locals
3665 (not (file-remote-p (or (buffer-file-name) 3674 (not (file-remote-p (or (buffer-file-name)
3666 default-directory))))) 3675 default-directory)))))
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index ea318ec3250..5e9ba6d9cea 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -5133,7 +5133,7 @@ Other orders of $ and _ seem to all work just fine.")
5133 (forward-line 1)) 5133 (forward-line 1))
5134 ;; Would like to look for a "Total" line, or a "Directory" line to 5134 ;; Would like to look for a "Total" line, or a "Directory" line to
5135 ;; make sure that the listing isn't complete garbage before putting 5135 ;; make sure that the listing isn't complete garbage before putting
5136 ;; in "." and "..", but we can't even count on all VAX's giving us 5136 ;; in "." and "..", but we can't count on VMS giving us
5137 ;; either of these. 5137 ;; either of these.
5138 (puthash "." t tbl) 5138 (puthash "." t tbl)
5139 (puthash ".." t tbl)) 5139 (puthash ".." t tbl))
diff --git a/lisp/tutorial.el b/lisp/tutorial.el
index 011461119fc..39eb9e8b9aa 100644
--- a/lisp/tutorial.el
+++ b/lisp/tutorial.el
@@ -829,10 +829,9 @@ Run the Viper tutorial? "))
829 (progn 829 (progn
830 (insert-file-contents (tutorial--saved-file)) 830 (insert-file-contents (tutorial--saved-file))
831 (let ((enable-local-variables :safe) 831 (let ((enable-local-variables :safe)
832 (enable-local-eval nil)) 832 (enable-local-eval nil)
833 (enable-dir-local-variables nil)) ; bug#11127
833 (hack-local-variables)) 834 (hack-local-variables))
834 ;; FIXME? What we actually want is to ignore dir-locals (?).
835 (setq buffer-read-only nil) ; bug#11118
836 (goto-char (point-min)) 835 (goto-char (point-min))
837 (setq old-tut-point 836 (setq old-tut-point
838 (string-to-number 837 (string-to-number
@@ -849,10 +848,9 @@ Run the Viper tutorial? "))
849 (setq tutorial--point-before-chkeys (point-marker))) 848 (setq tutorial--point-before-chkeys (point-marker)))
850 (insert-file-contents (expand-file-name filename tutorial-directory)) 849 (insert-file-contents (expand-file-name filename tutorial-directory))
851 (let ((enable-local-variables :safe) 850 (let ((enable-local-variables :safe)
852 (enable-local-eval nil)) 851 (enable-local-eval nil)
852 (enable-dir-local-variables nil)) ; bug#11127
853 (hack-local-variables)) 853 (hack-local-variables))
854 ;; FIXME? What we actually want is to ignore dir-locals (?).
855 (setq buffer-read-only nil) ; bug#11118
856 (forward-line) 854 (forward-line)
857 (setq tutorial--point-before-chkeys (point-marker))) 855 (setq tutorial--point-before-chkeys (point-marker)))
858 856
diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el
index 8b4ff792969..0fc0d2e3f73 100644
--- a/lisp/vc/diff.el
+++ b/lisp/vc/diff.el
@@ -114,6 +114,13 @@ specified in the variable `diff-switches' are passed to the diff command."
114 tempfile)) 114 tempfile))
115 (file-local-copy file-or-buf))) 115 (file-local-copy file-or-buf)))
116 116
117(defvar diff-use-labels 'check
118 "Whether `diff-command' understands the \"--label\" option.
119Possible values are:
120 t -- yes, it does
121 nil -- no, it does not
122 check -- try to probe whether it does")
123
117(defun diff-no-select (old new &optional switches no-async buf) 124(defun diff-no-select (old new &optional switches no-async buf)
118 ;; Noninteractive helper for creating and reverting diff buffers 125 ;; Noninteractive helper for creating and reverting diff buffers
119 (unless (bufferp new) (setq new (expand-file-name new))) 126 (unless (bufferp new) (setq new (expand-file-name new)))
@@ -121,6 +128,11 @@ specified in the variable `diff-switches' are passed to the diff command."
121 (or switches (setq switches diff-switches)) ; If not specified, use default. 128 (or switches (setq switches diff-switches)) ; If not specified, use default.
122 (unless (listp switches) (setq switches (list switches))) 129 (unless (listp switches) (setq switches (list switches)))
123 (or buf (setq buf (get-buffer-create "*Diff*"))) 130 (or buf (setq buf (get-buffer-create "*Diff*")))
131 (when (eq 'check diff-use-labels)
132 (setq diff-use-labels
133 (with-temp-buffer
134 (when (ignore-errors (call-process diff-command nil t nil "--help"))
135 (if (search-backward "--label" nil t) t)))))
124 (let* ((old-alt (diff-file-local-copy old)) 136 (let* ((old-alt (diff-file-local-copy old))
125 (new-alt (diff-file-local-copy new)) 137 (new-alt (diff-file-local-copy new))
126 (command 138 (command
@@ -130,11 +142,14 @@ specified in the variable `diff-switches' are passed to the diff command."
130 ,@switches 142 ,@switches
131 ,@(mapcar #'shell-quote-argument 143 ,@(mapcar #'shell-quote-argument
132 (nconc 144 (nconc
133 (when (or old-alt new-alt) 145 (and (or old-alt new-alt)
134 (list "-L" (if (stringp old) 146 (eq diff-use-labels t)
135 old (prin1-to-string old)) 147 (list "--label"
136 "-L" (if (stringp new) 148 (if (stringp old) old
137 new (prin1-to-string new)))) 149 (prin1-to-string old))
150 "--label"
151 (if (stringp new) new
152 (prin1-to-string new))))
138 (list (or old-alt old) 153 (list (or old-alt old)
139 (or new-alt new))))) 154 (or new-alt new)))))
140 " ")) 155 " "))
diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el
index fcdd792a69b..923888b460b 100644
--- a/lisp/vc/vc-svn.el
+++ b/lisp/vc/vc-svn.el
@@ -50,14 +50,21 @@
50 :type 'string 50 :type 'string
51 :group 'vc-svn) 51 :group 'vc-svn)
52 52
53(defcustom vc-svn-global-switches nil 53;; Might be nice if svn defaulted to non-interactive if stdin not tty.
54 "Global switches to pass to any SVN command." 54;; http://svn.haxx.se/dev/archive-2008-05/0762.shtml
55;; http://svn.haxx.se/dev/archive-2009-04/0094.shtml
56;; Maybe newer ones do?
57(defcustom vc-svn-global-switches (unless (eq system-type 'darwin) ; bug#13513
58 '("--non-interactive"))
59 "Global switches to pass to any SVN command.
60The option \"--non-interactive\" is often needed to prevent SVN
61hanging while prompting for authorization."
55 :type '(choice (const :tag "None" nil) 62 :type '(choice (const :tag "None" nil)
56 (string :tag "Argument String") 63 (string :tag "Argument String")
57 (repeat :tag "Argument List" 64 (repeat :tag "Argument List"
58 :value ("") 65 :value ("")
59 string)) 66 string))
60 :version "22.1" 67 :version "24.4"
61 :group 'vc-svn) 68 :group 'vc-svn)
62 69
63(defcustom vc-svn-register-switches nil 70(defcustom vc-svn-register-switches nil
@@ -600,19 +607,11 @@ NAME is assumed to be a URL."
600(defun vc-svn-command (buffer okstatus file-or-list &rest flags) 607(defun vc-svn-command (buffer okstatus file-or-list &rest flags)
601 "A wrapper around `vc-do-command' for use in vc-svn.el. 608 "A wrapper around `vc-do-command' for use in vc-svn.el.
602The difference to vc-do-command is that this function always invokes `svn', 609The difference to vc-do-command is that this function always invokes `svn',
603and that it passes \"--non-interactive\" and `vc-svn-global-switches' to 610and that it passes `vc-svn-global-switches' to it before FLAGS."
604it before FLAGS."
605 ;; Might be nice if svn defaulted to non-interactive if stdin not tty.
606 ;; http://svn.haxx.se/dev/archive-2008-05/0762.shtml
607 ;; http://svn.haxx.se/dev/archive-2009-04/0094.shtml
608 ;; Maybe newer ones do?
609 (or (member "--non-interactive"
610 (setq flags (if (stringp vc-svn-global-switches)
611 (cons vc-svn-global-switches flags)
612 (append vc-svn-global-switches flags))))
613 (setq flags (cons "--non-interactive" flags)))
614 (apply 'vc-do-command (or buffer "*vc*") okstatus vc-svn-program file-or-list 611 (apply 'vc-do-command (or buffer "*vc*") okstatus vc-svn-program file-or-list
615 flags)) 612 (if (stringp vc-svn-global-switches)
613 (cons vc-svn-global-switches flags)
614 (append vc-svn-global-switches flags))))
616 615
617(defun vc-svn-repository-hostname (dirname) 616(defun vc-svn-repository-hostname (dirname)
618 (with-temp-buffer 617 (with-temp-buffer
diff --git a/src/ChangeLog b/src/ChangeLog
index 9d8540075de..b3d3958853b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,47 @@
12013-02-11 Paul Eggert <eggert@cs.ucla.edu>
2
3 Clean up read_key_sequence a tiny bit more.
4 * keyboard.c (read_char_x_menu_prompt) [HAVE_MENUS]:
5 (read_key_sequence): Remove unused locals.
6
72013-02-11 Stefan Monnier <monnier@iro.umontreal.ca>
8
9 Clean up read_key_sequence a bit; reread active keymaps after first event.
10 * keyboard.c (read_char, read_char_x_menu_prompt)
11 (read_char_minibuf_menu_prompt):
12 Replace nmaps+maps with a single `map' arg.
13 (follow_key): Operate on a single map.
14 (active_maps): New function.
15 (test_undefined): Also return true for nil bindings.
16 (read_key_sequence): Use active_maps to replace the arrays of keymaps with
17 a single (composed) keymap. Remember `first_event' to choose the right
18 set of active keymaps. Recompute the set of keymaps after receiving
19 the first event. Remove GOBBLE_FIRST_EVENT.
20 (syms_of_keyboard): Remove inhibit_local_menu_bar_menus.
21 * keyboard.h (read_char): Update declaration.
22 * lread.c (read_filtered_event): Adjust call to read_char.
23
242013-02-11 Eli Zaretskii <eliz@gnu.org>
25
26 * xdisp.c (move_it_vertically_backward, move_it_by_lines):
27 Don't use the limitation on backwards movement when lines are truncated
28 in the window. (Bug#13675)
29
302013-02-11 Dmitry Antipov <dmantipov@yandex.ru>
31
32 * marker.c (set_marker_internal): If desired position is passed
33 as a marker, avoid call to buf_charpos_to_bytepos.
34 * window.c (Fset_window_point): Omit redundant type checking.
35 (Fset_window_start): Likewise. Format comment.
36 (window_scroll_pixel_based): Use set_marker_restricted_both
37 with character and byte positions obtained from an iterator.
38 (Fset_window_configuration): Use set_marker_restricted_both.
39 * xdisp.c (message_dolog): Likewise.
40
12013-02-10 Eli Zaretskii <eliz@gnu.org> 412013-02-10 Eli Zaretskii <eliz@gnu.org>
2 42
3 * xdisp.c (move_it_vertically_backward, move_it_by_lines): When 43 * xdisp.c (move_it_vertically_backward, move_it_by_lines):
4 text lines are longer than window's screen lines, don't move back 44 When text lines are longer than window's screen lines, don't move back
5 too far. This speeds up some redisplay operations. (Bug#13675) 45 too far. This speeds up some redisplay operations. (Bug#13675)
6 46
72013-02-10 Dmitry Antipov <dmantipov@yandex.ru> 472013-02-10 Dmitry Antipov <dmantipov@yandex.ru>
@@ -123,8 +163,8 @@
123 * xdisp.c (window_buffer_changed): region_showing can be negative, 163 * xdisp.c (window_buffer_changed): region_showing can be negative,
124 which still means region is being displayed. 164 which still means region is being displayed.
125 (redisplay_internal): Resurrect code that forced redisplay of the 165 (redisplay_internal): Resurrect code that forced redisplay of the
126 whole window when showing region and the mark has changed. Record 166 whole window when showing region and the mark has changed.
127 the new mark position to allow redisplay optimizations. 167 Record the new mark position to allow redisplay optimizations.
128 (display_line): If it->region_beg_charpos is non-zero, set the 168 (display_line): If it->region_beg_charpos is non-zero, set the
129 window's region_showing member to -1. (Bug#13623) (Bug#13626) 169 window's region_showing member to -1. (Bug#13623) (Bug#13626)
130 170
@@ -179,8 +219,8 @@
179 * dired.c (file_name_completion): Don't call Fdirectory_file_name 219 * dired.c (file_name_completion): Don't call Fdirectory_file_name
180 with an encoded file name. 220 with an encoded file name.
181 221
182 * w32proc.c (Fw32_short_file_name, Fw32_long_file_name): Adjust 222 * w32proc.c (Fw32_short_file_name, Fw32_long_file_name):
183 calls to dostounix_filename. 223 Adjust calls to dostounix_filename.
184 224
185 * w32fns.c (Fx_file_dialog): Adjust call to dostounix_filename. 225 * w32fns.c (Fx_file_dialog): Adjust call to dostounix_filename.
186 226
@@ -275,8 +315,8 @@
275 closing it. (Bug#13546) 315 closing it. (Bug#13546)
276 316
277 * w32.c (parse_root, get_volume_info, readdir, read_unc_volume) 317 * w32.c (parse_root, get_volume_info, readdir, read_unc_volume)
278 (logon_network_drive, stat_worker, symlink, chase_symlinks): Use 318 (logon_network_drive, stat_worker, symlink, chase_symlinks):
279 CharNextExA and CharPrevExA to iterate over file names encoded in 319 Use CharNextExA and CharPrevExA to iterate over file names encoded in
280 DBCS. (Bug#13553) 320 DBCS. (Bug#13553)
281 321
282 * w32.c (w32_get_long_filename, init_environment, readlink): 322 * w32.c (w32_get_long_filename, init_environment, readlink):
@@ -316,8 +356,8 @@
316 (normalize_filename, readdir): Use it to detect locales where ANSI 356 (normalize_filename, readdir): Use it to detect locales where ANSI
317 encoding of file names uses a double-byte character set (DBCS). 357 encoding of file names uses a double-byte character set (DBCS).
318 If a DBCS encoding is used, advance by characters using 358 If a DBCS encoding is used, advance by characters using
319 CharNextExA, instead of incrementing a 'char *' pointer. Use 359 CharNextExA, instead of incrementing a 'char *' pointer.
320 _mbslwr instead of _strlwr. (Bug#13515) 360 Use _mbslwr instead of _strlwr. (Bug#13515)
321 361
322 * w32heap.c (allocate_heap) [!_WIN64]: Decrease the initial 362 * w32heap.c (allocate_heap) [!_WIN64]: Decrease the initial
323 request of memory reservation to 1.7GB. (Bug#13065) 363 request of memory reservation to 1.7GB. (Bug#13065)
@@ -458,8 +498,8 @@
458 segfault when there are lots of overlays. 498 segfault when there are lots of overlays.
459 499
460 * buffer.c (sort_overlays): Use SAFE_NALLOCA, to avoid segfault 500 * buffer.c (sort_overlays): Use SAFE_NALLOCA, to avoid segfault
461 when there are lots of overlays. See 501 when there are lots of overlays.
462 http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00421.html 502 See http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00421.html
463 for the details and a way to reproduce. 503 for the details and a way to reproduce.
464 504
4652013-01-19 Paul Eggert <eggert@cs.ucla.edu> 5052013-01-19 Paul Eggert <eggert@cs.ucla.edu>
@@ -517,8 +557,8 @@
517 557
5182013-01-18 Dmitry Antipov <dmantipov@yandex.ru> 5582013-01-18 Dmitry Antipov <dmantipov@yandex.ru>
519 559
520 Fix crash when inserting data from non-regular files. See 560 Fix crash when inserting data from non-regular files.
521 http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00406.html 561 See http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00406.html
522 for the error description produced by valgrind. 562 for the error description produced by valgrind.
523 * fileio.c (read_non_regular): Rename to read_contents. 563 * fileio.c (read_non_regular): Rename to read_contents.
524 Free Lisp_Save_Value object used to pass parameters. 564 Free Lisp_Save_Value object used to pass parameters.
@@ -570,8 +610,8 @@
570 (map_keymap_char_table_item): Adjust accordingly. 610 (map_keymap_char_table_item): Adjust accordingly.
571 * fileio.c (non_regular_fd, non_regular_inserted) 611 * fileio.c (non_regular_fd, non_regular_inserted)
572 (non_regular_nbytes): Remove. 612 (non_regular_nbytes): Remove.
573 (Finsert_file_contents): Convert trytry to ptrdiff_t. Use 613 (Finsert_file_contents): Convert trytry to ptrdiff_t.
574 format_save_value to pass parameters to read_non_regular. 614 Use format_save_value to pass parameters to read_non_regular.
575 (read_non_regular): Use XSAVE_ macros to extract parameters. 615 (read_non_regular): Use XSAVE_ macros to extract parameters.
576 Adjust comment. 616 Adjust comment.
577 * xmenu.c (xmenu_show) [!USE_X_TOOLKIT && !USE_GTK]: Use 617 * xmenu.c (xmenu_show) [!USE_X_TOOLKIT && !USE_GTK]: Use
@@ -698,8 +738,8 @@
698 738
6992013-01-11 Aaron S. Hawley <Aaron.Hawley@vtinfo.com> 7392013-01-11 Aaron S. Hawley <Aaron.Hawley@vtinfo.com>
700 740
701 * insdel.c (Fcombine_after_change_execute, syms_of_insdel): Fix 741 * insdel.c (Fcombine_after_change_execute, syms_of_insdel):
702 ambiguous doc string cross-reference(s). 742 Fix ambiguous doc string cross-reference(s).
703 743
704 * keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous 744 * keyboard.c (Fcommand_execute, syms_of_keyboard): Fix ambiguous
705 doc string cross-reference(s). 745 doc string cross-reference(s).
diff --git a/src/cm.c b/src/cm.c
index 842633aceec..3a5f927eda3 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -28,8 +28,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28#include "termchar.h" 28#include "termchar.h"
29#include "tparam.h" 29#include "tparam.h"
30 30
31#define BIG 9999 /* 9999 good on VAXen. For 16 bit machines 31#define BIG 9999 /* Good on 32-bit hosts. */
32 use about 2000.... */
33 32
34int cost; /* sums up costs */ 33int cost; /* sums up costs */
35 34
diff --git a/src/fileio.c b/src/fileio.c
index ddf23867104..98a9b32ea91 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -133,9 +133,6 @@ static Lisp_Object Qwrite_region_annotate_functions;
133 is added here. */ 133 is added here. */
134static Lisp_Object Vwrite_region_annotation_buffers; 134static Lisp_Object Vwrite_region_annotation_buffers;
135 135
136#ifdef HAVE_FSYNC
137#endif
138
139static Lisp_Object Qdelete_by_moving_to_trash; 136static Lisp_Object Qdelete_by_moving_to_trash;
140 137
141/* Lisp function for moving files to trash. */ 138/* Lisp function for moving files to trash. */
@@ -4965,7 +4962,7 @@ This calls `write-region-annotate-functions' at the start, and
4965 immediate_quit = 0; 4962 immediate_quit = 0;
4966 4963
4967#ifdef HAVE_FSYNC 4964#ifdef HAVE_FSYNC
4968 /* Note fsync appears to change the modtime on BSD4.2 (both vax and sun). 4965 /* fsync appears to change the modtime on BSD4.2.
4969 Disk full in NFS may be reported here. */ 4966 Disk full in NFS may be reported here. */
4970 /* mib says that closing the file will try to write as fast as NFS can do 4967 /* mib says that closing the file will try to write as fast as NFS can do
4971 it, and that means the fsync here is not crucial for autosave files. */ 4968 it, and that means the fsync here is not crucial for autosave files. */
diff --git a/src/keyboard.c b/src/keyboard.c
index f5728009cf7..4a92cea30c8 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -420,10 +420,9 @@ static void (*keyboard_init_hook) (void);
420 420
421static bool get_input_pending (int); 421static bool get_input_pending (int);
422static bool readable_events (int); 422static bool readable_events (int);
423static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *, 423static Lisp_Object read_char_x_menu_prompt (Lisp_Object,
424 Lisp_Object, bool *); 424 Lisp_Object, bool *);
425static Lisp_Object read_char_minibuf_menu_prompt (int, ptrdiff_t, 425static Lisp_Object read_char_minibuf_menu_prompt (int, Lisp_Object);
426 Lisp_Object *);
427static Lisp_Object make_lispy_event (struct input_event *); 426static Lisp_Object make_lispy_event (struct input_event *);
428static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object, 427static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object,
429 enum scroll_bar_part, 428 enum scroll_bar_part,
@@ -2234,13 +2233,12 @@ do { if (! polling_stopped_here) stop_polling (); \
2234do { if (polling_stopped_here) start_polling (); \ 2233do { if (polling_stopped_here) start_polling (); \
2235 polling_stopped_here = 0; } while (0) 2234 polling_stopped_here = 0; } while (0)
2236 2235
2237/* read a character from the keyboard; call the redisplay if needed */ 2236/* Read a character from the keyboard; call the redisplay if needed. */
2238/* commandflag 0 means do not autosave, but do redisplay. 2237/* commandflag 0 means do not autosave, but do redisplay.
2239 -1 means do not redisplay, but do autosave. 2238 -1 means do not redisplay, but do autosave.
2240 1 means do both. */ 2239 1 means do both. */
2241 2240
2242/* The arguments MAPS and NMAPS are for menu prompting. 2241/* The arguments MAP is for menu prompting. MAP is a keymap.
2243 MAPS is an array of keymaps; NMAPS is the length of MAPS.
2244 2242
2245 PREV_EVENT is the previous input event, or nil if we are reading 2243 PREV_EVENT is the previous input event, or nil if we are reading
2246 the first event of a key sequence (or not reading a key sequence). 2244 the first event of a key sequence (or not reading a key sequence).
@@ -2262,7 +2260,7 @@ do { if (polling_stopped_here) start_polling (); \
2262 Value is t if we showed a menu and the user rejected it. */ 2260 Value is t if we showed a menu and the user rejected it. */
2263 2261
2264Lisp_Object 2262Lisp_Object
2265read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, 2263read_char (int commandflag, Lisp_Object map,
2266 Lisp_Object prev_event, 2264 Lisp_Object prev_event,
2267 bool *used_mouse_menu, EMACS_TIME *end_time) 2265 bool *used_mouse_menu, EMACS_TIME *end_time)
2268{ 2266{
@@ -2410,7 +2408,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2410 goto reread_first; 2408 goto reread_first;
2411 } 2409 }
2412 2410
2413 /* if redisplay was requested */ 2411 /* If redisplay was requested. */
2414 if (commandflag >= 0) 2412 if (commandflag >= 0)
2415 { 2413 {
2416 bool echo_current = EQ (echo_message_buffer, echo_area_buffer[0]); 2414 bool echo_current = EQ (echo_message_buffer, echo_area_buffer[0]);
@@ -2419,7 +2417,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2419 user-visible, such as X selection_request events. */ 2417 user-visible, such as X selection_request events. */
2420 if (input_pending 2418 if (input_pending
2421 || detect_input_pending_run_timers (0)) 2419 || detect_input_pending_run_timers (0))
2422 swallow_events (0); /* may clear input_pending */ 2420 swallow_events (0); /* May clear input_pending. */
2423 2421
2424 /* Redisplay if no pending input. */ 2422 /* Redisplay if no pending input. */
2425 while (!input_pending) 2423 while (!input_pending)
@@ -2489,13 +2487,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2489 menu prompting. If EVENT_HAS_PARAMETERS then we are reading 2487 menu prompting. If EVENT_HAS_PARAMETERS then we are reading
2490 after a mouse event so don't try a minibuf menu. */ 2488 after a mouse event so don't try a minibuf menu. */
2491 c = Qnil; 2489 c = Qnil;
2492 if (nmaps > 0 && INTERACTIVE 2490 if (KEYMAPP (map) && INTERACTIVE
2493 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) 2491 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event)
2494 /* Don't bring up a menu if we already have another event. */ 2492 /* Don't bring up a menu if we already have another event. */
2495 && NILP (Vunread_command_events) 2493 && NILP (Vunread_command_events)
2496 && !detect_input_pending_run_timers (0)) 2494 && !detect_input_pending_run_timers (0))
2497 { 2495 {
2498 c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps); 2496 c = read_char_minibuf_menu_prompt (commandflag, map);
2499 2497
2500 if (INTEGERP (c) && XINT (c) == -2) 2498 if (INTEGERP (c) && XINT (c) == -2)
2501 return c; /* wrong_kboard_jmpbuf */ 2499 return c; /* wrong_kboard_jmpbuf */
@@ -2619,7 +2617,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2619 because the recursive call of read_char in read_char_minibuf_menu_prompt 2617 because the recursive call of read_char in read_char_minibuf_menu_prompt
2620 does not pass on any keymaps. */ 2618 does not pass on any keymaps. */
2621 2619
2622 if (nmaps > 0 && INTERACTIVE 2620 if (KEYMAPP (map) && INTERACTIVE
2623 && !NILP (prev_event) 2621 && !NILP (prev_event)
2624 && EVENT_HAS_PARAMETERS (prev_event) 2622 && EVENT_HAS_PARAMETERS (prev_event)
2625 && !EQ (XCAR (prev_event), Qmenu_bar) 2623 && !EQ (XCAR (prev_event), Qmenu_bar)
@@ -2627,7 +2625,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2627 /* Don't bring up a menu if we already have another event. */ 2625 /* Don't bring up a menu if we already have another event. */
2628 && NILP (Vunread_command_events)) 2626 && NILP (Vunread_command_events))
2629 { 2627 {
2630 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); 2628 c = read_char_x_menu_prompt (map, prev_event, used_mouse_menu);
2631 2629
2632 /* Now that we have read an event, Emacs is not idle. */ 2630 /* Now that we have read an event, Emacs is not idle. */
2633 if (!end_time) 2631 if (!end_time)
@@ -3005,7 +3003,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
3005 3003
3006 /* If we are not reading a key sequence, 3004 /* If we are not reading a key sequence,
3007 never use the echo area. */ 3005 never use the echo area. */
3008 if (maps == 0) 3006 if (!KEYMAPP (map))
3009 { 3007 {
3010 specbind (Qinput_method_use_echo_area, Qt); 3008 specbind (Qinput_method_use_echo_area, Qt);
3011 } 3009 }
@@ -3098,7 +3096,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
3098 last_input_event = c; 3096 last_input_event = c;
3099 num_input_events++; 3097 num_input_events++;
3100 3098
3101 /* Process the help character specially if enabled */ 3099 /* Process the help character specially if enabled. */
3102 if (!NILP (Vhelp_form) && help_char_p (c)) 3100 if (!NILP (Vhelp_form) && help_char_p (c))
3103 { 3101 {
3104 ptrdiff_t count = SPECPDL_INDEX (); 3102 ptrdiff_t count = SPECPDL_INDEX ();
@@ -3112,13 +3110,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
3112 cancel_echoing (); 3110 cancel_echoing ();
3113 do 3111 do
3114 { 3112 {
3115 c = read_char (0, 0, 0, Qnil, 0, NULL); 3113 c = read_char (0, Qnil, Qnil, 0, NULL);
3116 if (EVENT_HAS_PARAMETERS (c) 3114 if (EVENT_HAS_PARAMETERS (c)
3117 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_click)) 3115 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_click))
3118 XSETCAR (help_form_saved_window_configs, Qnil); 3116 XSETCAR (help_form_saved_window_configs, Qnil);
3119 } 3117 }
3120 while (BUFFERP (c)); 3118 while (BUFFERP (c));
3121 /* Remove the help from the frame */ 3119 /* Remove the help from the frame. */
3122 unbind_to (count, Qnil); 3120 unbind_to (count, Qnil);
3123 3121
3124 redisplay (); 3122 redisplay ();
@@ -3126,7 +3124,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
3126 { 3124 {
3127 cancel_echoing (); 3125 cancel_echoing ();
3128 do 3126 do
3129 c = read_char (0, 0, 0, Qnil, 0, NULL); 3127 c = read_char (0, Qnil, Qnil, 0, NULL);
3130 while (BUFFERP (c)); 3128 while (BUFFERP (c));
3131 } 3129 }
3132 } 3130 }
@@ -8332,9 +8330,9 @@ init_tool_bar_items (Lisp_Object reuse)
8332static void 8330static void
8333append_tool_bar_item (void) 8331append_tool_bar_item (void)
8334{ 8332{
8335 ptrdiff_t incr = 8333 ptrdiff_t incr
8336 (ntool_bar_items 8334 = (ntool_bar_items
8337 - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS)); 8335 - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS));
8338 8336
8339 /* Enlarge tool_bar_items_vector if necessary. */ 8337 /* Enlarge tool_bar_items_vector if necessary. */
8340 if (0 < incr) 8338 if (0 < incr)
@@ -8352,8 +8350,8 @@ append_tool_bar_item (void)
8352 8350
8353 8351
8354 8352
8355/* Read a character using menus based on maps in the array MAPS. 8353/* Read a character using menus based on the keymap MAP.
8356 NMAPS is the length of MAPS. Return nil if there are no menus in the maps. 8354 Return nil if there are no menus in the maps.
8357 Return t if we displayed a menu but the user rejected it. 8355 Return t if we displayed a menu but the user rejected it.
8358 8356
8359 PREV_EVENT is the previous input event, or nil if we are reading 8357 PREV_EVENT is the previous input event, or nil if we are reading
@@ -8373,28 +8371,17 @@ append_tool_bar_item (void)
8373 and do auto-saving in the inner call of read_char. */ 8371 and do auto-saving in the inner call of read_char. */
8374 8372
8375static Lisp_Object 8373static Lisp_Object
8376read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, 8374read_char_x_menu_prompt (Lisp_Object map,
8377 Lisp_Object prev_event, bool *used_mouse_menu) 8375 Lisp_Object prev_event, bool *used_mouse_menu)
8378{ 8376{
8379#ifdef HAVE_MENUS
8380 ptrdiff_t mapno;
8381#endif
8382
8383 if (used_mouse_menu) 8377 if (used_mouse_menu)
8384 *used_mouse_menu = 0; 8378 *used_mouse_menu = 0;
8385 8379
8386 /* Use local over global Menu maps */ 8380 /* Use local over global Menu maps. */
8387 8381
8388 if (! menu_prompting) 8382 if (! menu_prompting)
8389 return Qnil; 8383 return Qnil;
8390 8384
8391 /* Optionally disregard all but the global map. */
8392 if (inhibit_local_menu_bar_menus)
8393 {
8394 maps += (nmaps - 1);
8395 nmaps = 1;
8396 }
8397
8398#ifdef HAVE_MENUS 8385#ifdef HAVE_MENUS
8399 /* If we got to this point via a mouse click, 8386 /* If we got to this point via a mouse click,
8400 use a real menu for mouse selection. */ 8387 use a real menu for mouse selection. */
@@ -8403,16 +8390,9 @@ read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps,
8403 && !EQ (XCAR (prev_event), Qtool_bar)) 8390 && !EQ (XCAR (prev_event), Qtool_bar))
8404 { 8391 {
8405 /* Display the menu and get the selection. */ 8392 /* Display the menu and get the selection. */
8406 Lisp_Object *realmaps = alloca (nmaps * sizeof *realmaps);
8407 Lisp_Object value; 8393 Lisp_Object value;
8408 ptrdiff_t nmaps1 = 0;
8409 8394
8410 /* Use the maps that are not nil. */ 8395 value = Fx_popup_menu (prev_event, get_keymap (map, 0, 1));
8411 for (mapno = 0; mapno < nmaps; mapno++)
8412 if (!NILP (maps[mapno]))
8413 realmaps[nmaps1++] = maps[mapno];
8414
8415 value = Fx_popup_menu (prev_event, Flist (nmaps1, realmaps));
8416 if (CONSP (value)) 8396 if (CONSP (value))
8417 { 8397 {
8418 Lisp_Object tem; 8398 Lisp_Object tem;
@@ -8454,9 +8434,8 @@ read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps,
8454 8434
8455static Lisp_Object 8435static Lisp_Object
8456read_char_minibuf_menu_prompt (int commandflag, 8436read_char_minibuf_menu_prompt (int commandflag,
8457 ptrdiff_t nmaps, Lisp_Object *maps) 8437 Lisp_Object map)
8458{ 8438{
8459 ptrdiff_t mapno;
8460 register Lisp_Object name; 8439 register Lisp_Object name;
8461 ptrdiff_t nlength; 8440 ptrdiff_t nlength;
8462 /* FIXME: Use the minibuffer's frame width. */ 8441 /* FIXME: Use the minibuffer's frame width. */
@@ -8467,18 +8446,12 @@ read_char_minibuf_menu_prompt (int commandflag,
8467 Lisp_Object prompt_strings = Qnil; 8446 Lisp_Object prompt_strings = Qnil;
8468 8447
8469 vector = Qnil; 8448 vector = Qnil;
8470 name = Qnil;
8471 8449
8472 if (! menu_prompting) 8450 if (! menu_prompting)
8473 return Qnil; 8451 return Qnil;
8474 8452
8475 /* Get the menu name from the first map that has one (a prompt string). */ 8453 map = get_keymap (map, 0, 1);
8476 for (mapno = 0; mapno < nmaps; mapno++) 8454 name = Fkeymap_prompt (map);
8477 {
8478 name = Fkeymap_prompt (maps[mapno]);
8479 if (!NILP (name))
8480 break;
8481 }
8482 8455
8483 /* If we don't have any menus, just read a character normally. */ 8456 /* If we don't have any menus, just read a character normally. */
8484 if (!STRINGP (name)) 8457 if (!STRINGP (name))
@@ -8486,15 +8459,13 @@ read_char_minibuf_menu_prompt (int commandflag,
8486 8459
8487#define PUSH_C_STR(str, listvar) \ 8460#define PUSH_C_STR(str, listvar) \
8488 listvar = Fcons (make_unibyte_string (str, strlen (str)), listvar) 8461 listvar = Fcons (make_unibyte_string (str, strlen (str)), listvar)
8489 8462
8490 /* Prompt string always starts with map's prompt, and a space. */ 8463 /* Prompt string always starts with map's prompt, and a space. */
8491 prompt_strings = Fcons (name, prompt_strings); 8464 prompt_strings = Fcons (name, prompt_strings);
8492 PUSH_C_STR (": ", prompt_strings); 8465 PUSH_C_STR (": ", prompt_strings);
8493 nlength = SCHARS (name) + 2; 8466 nlength = SCHARS (name) + 2;
8494 8467
8495 /* Start prompting at start of first map. */ 8468 rest = map;
8496 mapno = 0;
8497 rest = maps[mapno];
8498 8469
8499 /* Present the documented bindings, a line at a time. */ 8470 /* Present the documented bindings, a line at a time. */
8500 while (1) 8471 while (1)
@@ -8512,18 +8483,14 @@ read_char_minibuf_menu_prompt (int commandflag,
8512 8483
8513 /* FIXME: Use map_keymap to handle new keymap formats. */ 8484 /* FIXME: Use map_keymap to handle new keymap formats. */
8514 8485
8515 /* If reached end of map, start at beginning of next map. */ 8486 /* At end of map, wrap around if just starting,
8487 or end this line if already have something on it. */
8516 if (NILP (rest)) 8488 if (NILP (rest))
8517 { 8489 {
8518 mapno++; 8490 if (notfirst || nobindings)
8519 /* At end of last map, wrap around to first map if just starting, 8491 break;
8520 or end this line if already have something on it. */ 8492 else
8521 if (mapno == nmaps) 8493 rest = map;
8522 {
8523 mapno = 0;
8524 if (notfirst || nobindings) break;
8525 }
8526 rest = maps[mapno];
8527 } 8494 }
8528 8495
8529 /* Look at the next element of the map. */ 8496 /* Look at the next element of the map. */
@@ -8657,7 +8624,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8657 } 8624 }
8658 8625
8659 /* Prompt with that and read response. */ 8626 /* Prompt with that and read response. */
8660 message3_nolog (apply1 (intern ("concat"), menu_strings)); 8627 message3_nolog (apply1 (intern ("concat"), Fnreverse (menu_strings)));
8661 8628
8662 /* Make believe it's not a keyboard macro in case the help char 8629 /* Make believe it's not a keyboard macro in case the help char
8663 is pressed. Help characters are not recorded because menu prompting 8630 is pressed. Help characters are not recorded because menu prompting
@@ -8665,7 +8632,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8665 orig_defn_macro = KVAR (current_kboard, defining_kbd_macro); 8632 orig_defn_macro = KVAR (current_kboard, defining_kbd_macro);
8666 kset_defining_kbd_macro (current_kboard, Qnil); 8633 kset_defining_kbd_macro (current_kboard, Qnil);
8667 do 8634 do
8668 obj = read_char (commandflag, 0, 0, Qt, 0, NULL); 8635 obj = read_char (commandflag, Qnil, Qt, 0, NULL);
8669 while (BUFFERP (obj)); 8636 while (BUFFERP (obj));
8670 kset_defining_kbd_macro (current_kboard, orig_defn_macro); 8637 kset_defining_kbd_macro (current_kboard, orig_defn_macro);
8671 8638
@@ -8686,46 +8653,18 @@ read_char_minibuf_menu_prompt (int commandflag,
8686 8653
8687/* Reading key sequences. */ 8654/* Reading key sequences. */
8688 8655
8689/* Follow KEY in the maps in CURRENT[0..NMAPS-1], placing its bindings 8656static Lisp_Object
8690 in DEFS[0..NMAPS-1]. Set NEXT[i] to DEFS[i] if DEFS[i] is a 8657follow_key (Lisp_Object keymap, Lisp_Object key)
8691 keymap, or nil otherwise. Return the index of the first keymap in
8692 which KEY has any binding, or NMAPS if no map has a binding.
8693
8694 If KEY is a meta ASCII character, treat it like meta-prefix-char
8695 followed by the corresponding non-meta character. Keymaps in
8696 CURRENT with non-prefix bindings for meta-prefix-char become nil in
8697 NEXT.
8698
8699 If KEY has no bindings in any of the CURRENT maps, NEXT is left
8700 unmodified.
8701
8702 NEXT may be the same array as CURRENT. */
8703
8704static int
8705follow_key (Lisp_Object key, ptrdiff_t nmaps, Lisp_Object *current,
8706 Lisp_Object *defs, Lisp_Object *next)
8707{ 8658{
8708 ptrdiff_t i, first_binding; 8659 return access_keymap (get_keymap (keymap, 0, 1),
8709 8660 key, 1, 0, 1);
8710 first_binding = nmaps; 8661}
8711 for (i = nmaps - 1; i >= 0; i--)
8712 {
8713 if (! NILP (current[i]))
8714 {
8715 defs[i] = access_keymap (current[i], key, 1, 0, 1);
8716 if (! NILP (defs[i]))
8717 first_binding = i;
8718 }
8719 else
8720 defs[i] = Qnil;
8721 }
8722
8723 /* Given the set of bindings we've found, produce the next set of maps. */
8724 if (first_binding < nmaps)
8725 for (i = 0; i < nmaps; i++)
8726 next[i] = NILP (defs[i]) ? Qnil : get_keymap (defs[i], 0, 1);
8727 8662
8728 return first_binding; 8663static Lisp_Object
8664active_maps (Lisp_Object first_event)
8665{
8666 Lisp_Object position = INTEGERP (first_event) ? Qnil : first_event;
8667 return Fcons (Qkeymap, Fcurrent_active_maps (Qt, position));
8729} 8668}
8730 8669
8731/* Structure used to keep track of partial application of key remapping 8670/* Structure used to keep track of partial application of key remapping
@@ -8857,8 +8796,9 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
8857static bool 8796static bool
8858test_undefined (Lisp_Object binding) 8797test_undefined (Lisp_Object binding)
8859{ 8798{
8860 return (EQ (binding, Qundefined) 8799 return (NILP (binding)
8861 || (!NILP (binding) && SYMBOLP (binding) 8800 || EQ (binding, Qundefined)
8801 || (SYMBOLP (binding)
8862 && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined))); 8802 && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined)));
8863} 8803}
8864 8804
@@ -8904,7 +8844,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8904 bool dont_downcase_last, bool can_return_switch_frame, 8844 bool dont_downcase_last, bool can_return_switch_frame,
8905 bool fix_current_buffer) 8845 bool fix_current_buffer)
8906{ 8846{
8907 Lisp_Object from_string;
8908 ptrdiff_t count = SPECPDL_INDEX (); 8847 ptrdiff_t count = SPECPDL_INDEX ();
8909 8848
8910 /* How many keys there are in the current key sequence. */ 8849 /* How many keys there are in the current key sequence. */
@@ -8915,34 +8854,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8915 ptrdiff_t echo_start IF_LINT (= 0); 8854 ptrdiff_t echo_start IF_LINT (= 0);
8916 ptrdiff_t keys_start; 8855 ptrdiff_t keys_start;
8917 8856
8918 /* The number of keymaps we're scanning right now, and the number of 8857 Lisp_Object current_binding = Qnil;
8919 keymaps we have allocated space for. */ 8858 Lisp_Object first_event = Qnil;
8920 ptrdiff_t nmaps;
8921 ptrdiff_t nmaps_allocated = 0;
8922
8923 /* defs[0..nmaps-1] are the definitions of KEYBUF[0..t-1] in
8924 the current keymaps. */
8925 Lisp_Object *defs = NULL;
8926
8927 /* submaps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1]
8928 in the current keymaps, or nil where it is not a prefix. */
8929 Lisp_Object *submaps = NULL;
8930
8931 /* The local map to start out with at start of key sequence. */
8932 Lisp_Object orig_local_map;
8933 8859
8934 /* The map from the `keymap' property to start out with at start of
8935 key sequence. */
8936 Lisp_Object orig_keymap;
8937
8938 /* Positive if we have already considered switching to the local-map property
8939 of the place where a mouse click occurred. */
8940 int localized_local_map = 0;
8941
8942 /* The index in submaps[] of the first keymap that has a binding for
8943 this key sequence. In other words, the lowest i such that
8944 submaps[i] is non-nil. */
8945 ptrdiff_t first_binding;
8946 /* Index of the first key that has no binding. 8860 /* Index of the first key that has no binding.
8947 It is useless to try fkey.start larger than that. */ 8861 It is useless to try fkey.start larger than that. */
8948 int first_unbound; 8862 int first_unbound;
@@ -8985,11 +8899,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8985 While we're reading, we keep the event here. */ 8899 While we're reading, we keep the event here. */
8986 Lisp_Object delayed_switch_frame; 8900 Lisp_Object delayed_switch_frame;
8987 8901
8988 /* See the comment below... */
8989#if defined (GOBBLE_FIRST_EVENT)
8990 Lisp_Object first_event;
8991#endif
8992
8993 Lisp_Object original_uppercase IF_LINT (= Qnil); 8902 Lisp_Object original_uppercase IF_LINT (= Qnil);
8994 int original_uppercase_position = -1; 8903 int original_uppercase_position = -1;
8995 8904
@@ -9001,10 +8910,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9001 /* List of events for which a fake prefix key has been generated. */ 8910 /* List of events for which a fake prefix key has been generated. */
9002 Lisp_Object fake_prefixed_keys = Qnil; 8911 Lisp_Object fake_prefixed_keys = Qnil;
9003 8912
9004#if defined (GOBBLE_FIRST_EVENT)
9005 int junk;
9006#endif
9007
9008 struct gcpro gcpro1; 8913 struct gcpro gcpro1;
9009 8914
9010 GCPRO1 (fake_prefixed_keys); 8915 GCPRO1 (fake_prefixed_keys);
@@ -9040,21 +8945,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9040 keys_start = this_command_key_count; 8945 keys_start = this_command_key_count;
9041 this_single_command_key_start = keys_start; 8946 this_single_command_key_start = keys_start;
9042 8947
9043#if defined (GOBBLE_FIRST_EVENT)
9044 /* This doesn't quite work, because some of the things that read_char
9045 does cannot safely be bypassed. It seems too risky to try to make
9046 this work right. */
9047
9048 /* Read the first char of the sequence specially, before setting
9049 up any keymaps, in case a filter runs and switches buffers on us. */
9050 first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event,
9051 &junk, NULL);
9052#endif /* GOBBLE_FIRST_EVENT */
9053
9054 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
9055 orig_keymap = get_local_map (PT, current_buffer, Qkeymap);
9056 from_string = Qnil;
9057
9058 /* We jump here when we need to reinitialize fkey and keytran; this 8948 /* We jump here when we need to reinitialize fkey and keytran; this
9059 happens if we switch keyboards between rescans. */ 8949 happens if we switch keyboards between rescans. */
9060 replay_entire_sequence: 8950 replay_entire_sequence:
@@ -9079,59 +8969,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9079 keybuf with its symbol, or if the sequence starts with a mouse 8969 keybuf with its symbol, or if the sequence starts with a mouse
9080 click and we need to switch buffers, we jump back here to rebuild 8970 click and we need to switch buffers, we jump back here to rebuild
9081 the initial keymaps from the current buffer. */ 8971 the initial keymaps from the current buffer. */
9082 nmaps = 0; 8972 current_binding = active_maps (first_event);
9083
9084 if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
9085 {
9086 if (2 > nmaps_allocated)
9087 {
9088 submaps = alloca (2 * sizeof *submaps);
9089 defs = alloca (2 * sizeof *defs);
9090 nmaps_allocated = 2;
9091 }
9092 submaps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map);
9093 }
9094 else if (!NILP (Voverriding_local_map))
9095 {
9096 if (2 > nmaps_allocated)
9097 {
9098 submaps = alloca (2 * sizeof *submaps);
9099 defs = alloca (2 * sizeof *defs);
9100 nmaps_allocated = 2;
9101 }
9102 submaps[nmaps++] = Voverriding_local_map;
9103 }
9104 else
9105 {
9106 ptrdiff_t nminor;
9107 ptrdiff_t total;
9108 Lisp_Object *maps;
9109
9110 nminor = current_minor_maps (0, &maps);
9111 total = nminor + (!NILP (orig_keymap) ? 3 : 2);
9112
9113 if (total > nmaps_allocated)
9114 {
9115 submaps = alloca (total * sizeof *submaps);
9116 defs = alloca (total * sizeof *defs);
9117 nmaps_allocated = total;
9118 }
9119
9120 if (!NILP (orig_keymap))
9121 submaps[nmaps++] = orig_keymap;
9122
9123 memcpy (submaps + nmaps, maps, nminor * sizeof (submaps[0]));
9124
9125 nmaps += nminor;
9126
9127 submaps[nmaps++] = orig_local_map;
9128 }
9129 submaps[nmaps++] = current_global_map;
9130
9131 /* Find an accurate initial value for first_binding. */
9132 for (first_binding = 0; first_binding < nmaps; first_binding++)
9133 if (! NILP (submaps[first_binding]))
9134 break;
9135 8973
9136 /* Start from the beginning in keybuf. */ 8974 /* Start from the beginning in keybuf. */
9137 t = 0; 8975 t = 0;
@@ -9145,9 +8983,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9145 /* If the best binding for the current key sequence is a keymap, or 8983 /* If the best binding for the current key sequence is a keymap, or
9146 we may be looking at a function key's escape sequence, keep on 8984 we may be looking at a function key's escape sequence, keep on
9147 reading. */ 8985 reading. */
9148 while (first_binding < nmaps 8986 while (!NILP (current_binding)
9149 /* Keep reading as long as there's a prefix binding. */ 8987 /* Keep reading as long as there's a prefix binding. */
9150 ? !NILP (submaps[first_binding]) 8988 ? KEYMAPP (current_binding)
9151 /* Don't return in the middle of a possible function key sequence, 8989 /* Don't return in the middle of a possible function key sequence,
9152 if the only bindings we found were via case conversion. 8990 if the only bindings we found were via case conversion.
9153 Thus, if ESC O a has a function-key-map translation 8991 Thus, if ESC O a has a function-key-map translation
@@ -9171,7 +9009,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9171 just one key. */ 9009 just one key. */
9172 ptrdiff_t echo_local_start IF_LINT (= 0); 9010 ptrdiff_t echo_local_start IF_LINT (= 0);
9173 int keys_local_start; 9011 int keys_local_start;
9174 ptrdiff_t local_first_binding; 9012 Lisp_Object new_binding;
9175 9013
9176 eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); 9014 eassert (indec.end == t || (indec.end > t && indec.end <= mock_input));
9177 eassert (indec.start <= indec.end); 9015 eassert (indec.start <= indec.end);
@@ -9208,7 +9046,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9208 if (INTERACTIVE) 9046 if (INTERACTIVE)
9209 echo_local_start = echo_length (); 9047 echo_local_start = echo_length ();
9210 keys_local_start = this_command_key_count; 9048 keys_local_start = this_command_key_count;
9211 local_first_binding = first_binding;
9212 9049
9213 replay_key: 9050 replay_key:
9214 /* These are no-ops, unless we throw away a keystroke below and 9051 /* These are no-ops, unless we throw away a keystroke below and
@@ -9218,7 +9055,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9218 if (INTERACTIVE && t < mock_input) 9055 if (INTERACTIVE && t < mock_input)
9219 echo_truncate (echo_local_start); 9056 echo_truncate (echo_local_start);
9220 this_command_key_count = keys_local_start; 9057 this_command_key_count = keys_local_start;
9221 first_binding = local_first_binding;
9222 9058
9223 /* By default, assume each event is "real". */ 9059 /* By default, assume each event is "real". */
9224 last_real_key_start = t; 9060 last_real_key_start = t;
@@ -9243,8 +9079,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9243 { 9079 {
9244 KBOARD *interrupted_kboard = current_kboard; 9080 KBOARD *interrupted_kboard = current_kboard;
9245 struct frame *interrupted_frame = SELECTED_FRAME (); 9081 struct frame *interrupted_frame = SELECTED_FRAME ();
9246 key = read_char (NILP (prompt), nmaps, 9082 key = read_char (NILP (prompt),
9247 (Lisp_Object *) submaps, last_nonmenu_event, 9083 current_binding, last_nonmenu_event,
9248 &used_mouse_menu, NULL); 9084 &used_mouse_menu, NULL);
9249 if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */ 9085 if ((INTEGERP (key) && XINT (key) == -2) /* wrong_kboard_jmpbuf */
9250 /* When switching to a new tty (with a new keyboard), 9086 /* When switching to a new tty (with a new keyboard),
@@ -9299,8 +9135,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9299 KVAR (interrupted_kboard, kbd_queue))); 9135 KVAR (interrupted_kboard, kbd_queue)));
9300 } 9136 }
9301 mock_input = 0; 9137 mock_input = 0;
9302 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
9303 orig_keymap = get_local_map (PT, current_buffer, Qkeymap);
9304 goto replay_entire_sequence; 9138 goto replay_entire_sequence;
9305 } 9139 }
9306 } 9140 }
@@ -9341,12 +9175,11 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9341 { 9175 {
9342 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 9176 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
9343 Fkill_emacs (Qnil); 9177 Fkill_emacs (Qnil);
9344 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) 9178 if (XBUFFER (XWINDOW (selected_window)->buffer)
9179 != current_buffer)
9345 Fset_buffer (XWINDOW (selected_window)->buffer); 9180 Fset_buffer (XWINDOW (selected_window)->buffer);
9346 } 9181 }
9347 9182
9348 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
9349 orig_keymap = get_local_map (PT, current_buffer, Qkeymap);
9350 goto replay_sequence; 9183 goto replay_sequence;
9351 } 9184 }
9352 9185
@@ -9363,8 +9196,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9363 keybuf[t++] = key; 9196 keybuf[t++] = key;
9364 mock_input = t; 9197 mock_input = t;
9365 Vquit_flag = Qnil; 9198 Vquit_flag = Qnil;
9366 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
9367 orig_keymap = get_local_map (PT, current_buffer, Qkeymap);
9368 goto replay_sequence; 9199 goto replay_sequence;
9369 } 9200 }
9370 9201
@@ -9384,6 +9215,22 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9384 } 9215 }
9385 } 9216 }
9386 9217
9218 if (NILP (first_event))
9219 {
9220 first_event = key;
9221 /* Even if first_event does not specify a particular
9222 window/position, it's important to recompute the maps here
9223 since a long time might have passed since we entered
9224 read_key_sequence, and a timer (or process-filter or
9225 special-event-map, ...) might have switched the current buffer
9226 or the selected window from under us in the mean time. */
9227 if (fix_current_buffer
9228 && (XBUFFER (XWINDOW (selected_window)->buffer)
9229 != current_buffer))
9230 Fset_buffer (XWINDOW (selected_window)->buffer);
9231 current_binding = active_maps (first_event);
9232 }
9233
9387 GROW_RAW_KEYBUF; 9234 GROW_RAW_KEYBUF;
9388 ASET (raw_keybuf, raw_keybuf_count, key); 9235 ASET (raw_keybuf, raw_keybuf_count, key);
9389 raw_keybuf_count++; 9236 raw_keybuf_count++;
@@ -9405,16 +9252,11 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9405 or when user programs play with this-command-keys. */ 9252 or when user programs play with this-command-keys. */
9406 if (EVENT_HAS_PARAMETERS (key)) 9253 if (EVENT_HAS_PARAMETERS (key))
9407 { 9254 {
9408 Lisp_Object kind; 9255 Lisp_Object kind = EVENT_HEAD_KIND (EVENT_HEAD (key));
9409 Lisp_Object string;
9410
9411 kind = EVENT_HEAD_KIND (EVENT_HEAD (key));
9412 if (EQ (kind, Qmouse_click)) 9256 if (EQ (kind, Qmouse_click))
9413 { 9257 {
9414 Lisp_Object window, posn; 9258 Lisp_Object window = POSN_WINDOW (EVENT_START (key));
9415 9259 Lisp_Object posn = POSN_POSN (EVENT_START (key));
9416 window = POSN_WINDOW (EVENT_START (key));
9417 posn = POSN_POSN (EVENT_START (key));
9418 9260
9419 if (CONSP (posn) 9261 if (CONSP (posn)
9420 || (!NILP (fake_prefixed_keys) 9262 || (!NILP (fake_prefixed_keys)
@@ -9457,58 +9299,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9457 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 9299 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
9458 Fkill_emacs (Qnil); 9300 Fkill_emacs (Qnil);
9459 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); 9301 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer));
9460 orig_local_map = get_local_map (PT, current_buffer,
9461 Qlocal_map);
9462 orig_keymap = get_local_map (PT, current_buffer,
9463 Qkeymap);
9464 goto replay_sequence; 9302 goto replay_sequence;
9465 } 9303 }
9466
9467 /* For a mouse click, get the local text-property keymap
9468 of the place clicked on, rather than point. */
9469 if (CONSP (XCDR (key))
9470 && ! localized_local_map)
9471 {
9472 Lisp_Object map_here, start, pos;
9473
9474 localized_local_map = 1;
9475 start = EVENT_START (key);
9476
9477 if (CONSP (start) && POSN_INBUFFER_P (start))
9478 {
9479 pos = POSN_BUFFER_POSN (start);
9480 if (INTEGERP (pos)
9481 && XINT (pos) >= BEGV
9482 && XINT (pos) <= ZV)
9483 {
9484 map_here = get_local_map (XINT (pos),
9485 current_buffer,
9486 Qlocal_map);
9487 if (!EQ (map_here, orig_local_map))
9488 {
9489 orig_local_map = map_here;
9490 ++localized_local_map;
9491 }
9492
9493 map_here = get_local_map (XINT (pos),
9494 current_buffer,
9495 Qkeymap);
9496 if (!EQ (map_here, orig_keymap))
9497 {
9498 orig_keymap = map_here;
9499 ++localized_local_map;
9500 }
9501
9502 if (localized_local_map > 1)
9503 {
9504 keybuf[t] = key;
9505 mock_input = t + 1;
9506
9507 goto replay_sequence;
9508 }
9509 }
9510 }
9511 }
9512 } 9304 }
9513 9305
9514 /* Expand mode-line and scroll-bar events into two events: 9306 /* Expand mode-line and scroll-bar events into two events:
@@ -9529,63 +9321,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9529 prevent proper action when the event is pushed 9321 prevent proper action when the event is pushed
9530 back into unread-command-events. */ 9322 back into unread-command-events. */
9531 fake_prefixed_keys = Fcons (key, fake_prefixed_keys); 9323 fake_prefixed_keys = Fcons (key, fake_prefixed_keys);
9532
9533 /* If on a mode line string with a local keymap,
9534 reconsider the key sequence with that keymap. */
9535 if (string = POSN_STRING (EVENT_START (key)),
9536 (CONSP (string) && STRINGP (XCAR (string))))
9537 {
9538 Lisp_Object pos, map, map2;
9539
9540 pos = XCDR (string);
9541 string = XCAR (string);
9542 if (XINT (pos) >= 0
9543 && XINT (pos) < SCHARS (string))
9544 {
9545 map = Fget_text_property (pos, Qlocal_map, string);
9546 if (!NILP (map))
9547 orig_local_map = map;
9548 map2 = Fget_text_property (pos, Qkeymap, string);
9549 if (!NILP (map2))
9550 orig_keymap = map2;
9551 if (!NILP (map) || !NILP (map2))
9552 goto replay_sequence;
9553 }
9554 }
9555
9556 goto replay_key; 9324 goto replay_key;
9557 } 9325 }
9558 else if (NILP (from_string)
9559 && (string = POSN_STRING (EVENT_START (key)),
9560 (CONSP (string) && STRINGP (XCAR (string)))))
9561 {
9562 /* For a click on a string, i.e. overlay string or a
9563 string displayed via the `display' property,
9564 consider `local-map' and `keymap' properties of
9565 that string. */
9566 Lisp_Object pos, map, map2;
9567
9568 pos = XCDR (string);
9569 string = XCAR (string);
9570 if (XINT (pos) >= 0
9571 && XINT (pos) < SCHARS (string))
9572 {
9573 map = Fget_text_property (pos, Qlocal_map, string);
9574 if (!NILP (map))
9575 orig_local_map = map;
9576 map2 = Fget_text_property (pos, Qkeymap, string);
9577 if (!NILP (map2))
9578 orig_keymap = map2;
9579
9580 if (!NILP (map) || !NILP (map2))
9581 {
9582 from_string = string;
9583 keybuf[t++] = key;
9584 mock_input = t;
9585 goto replay_sequence;
9586 }
9587 }
9588 }
9589 } 9326 }
9590 else if (CONSP (XCDR (key)) 9327 else if (CONSP (XCDR (key))
9591 && CONSP (EVENT_START (key)) 9328 && CONSP (EVENT_START (key))
@@ -9601,7 +9338,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9601 if (bufsize - t <= 1) 9338 if (bufsize - t <= 1)
9602 error ("Key sequence too long"); 9339 error ("Key sequence too long");
9603 keybuf[t] = posn; 9340 keybuf[t] = posn;
9604 keybuf[t+1] = key; 9341 keybuf[t + 1] = key;
9605 9342
9606 /* Zap the position in key, so we know that we've 9343 /* Zap the position in key, so we know that we've
9607 expanded it, and don't try to do so again. */ 9344 expanded it, and don't try to do so again. */
@@ -9624,15 +9361,10 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9624 9361
9625 /* We have finally decided that KEY is something we might want 9362 /* We have finally decided that KEY is something we might want
9626 to look up. */ 9363 to look up. */
9627 first_binding = (follow_key (key, 9364 new_binding = follow_key (current_binding, key);
9628 nmaps - first_binding,
9629 submaps + first_binding,
9630 defs + first_binding,
9631 submaps + first_binding)
9632 + first_binding);
9633 9365
9634 /* If KEY wasn't bound, we'll try some fallbacks. */ 9366 /* If KEY wasn't bound, we'll try some fallbacks. */
9635 if (first_binding < nmaps) 9367 if (!NILP (new_binding))
9636 /* This is needed for the following scenario: 9368 /* This is needed for the following scenario:
9637 event 0: a down-event that gets dropped by calling replay_key. 9369 event 0: a down-event that gets dropped by calling replay_key.
9638 event 1: some normal prefix like C-h. 9370 event 1: some normal prefix like C-h.
@@ -9769,20 +9501,13 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9769 new_click 9501 new_click
9770 = Fcons (new_head, Fcons (EVENT_START (key), Qnil)); 9502 = Fcons (new_head, Fcons (EVENT_START (key), Qnil));
9771 9503
9772 /* Look for a binding for this new key. follow_key 9504 /* Look for a binding for this new key. */
9773 promises that it didn't munge submaps the 9505 new_binding = follow_key (current_binding, new_click);
9774 last time we called it, since key was unbound. */
9775 first_binding
9776 = (follow_key (new_click,
9777 nmaps - local_first_binding,
9778 submaps + local_first_binding,
9779 defs + local_first_binding,
9780 submaps + local_first_binding)
9781 + local_first_binding);
9782 9506
9783 /* If that click is bound, go for it. */ 9507 /* If that click is bound, go for it. */
9784 if (first_binding < nmaps) 9508 if (!NILP (new_binding))
9785 { 9509 {
9510 current_binding = new_binding;
9786 key = new_click; 9511 key = new_click;
9787 break; 9512 break;
9788 } 9513 }
@@ -9791,6 +9516,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9791 } 9516 }
9792 } 9517 }
9793 } 9518 }
9519 current_binding = new_binding;
9794 9520
9795 keybuf[t++] = key; 9521 keybuf[t++] = key;
9796 /* Normally, last_nonmenu_event gets the previous key we read. 9522 /* Normally, last_nonmenu_event gets the previous key we read.
@@ -9822,9 +9548,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9822 } 9548 }
9823 } 9549 }
9824 9550
9825 if (first_binding < nmaps 9551 if (!KEYMAPP (current_binding)
9826 && NILP (submaps[first_binding]) 9552 && !test_undefined (current_binding)
9827 && !test_undefined (defs[first_binding])
9828 && indec.start >= t) 9553 && indec.start >= t)
9829 /* There is a binding and it's not a prefix. 9554 /* There is a binding and it's not a prefix.
9830 (and it doesn't have any input-decode-map translation pending). 9555 (and it doesn't have any input-decode-map translation pending).
@@ -9853,8 +9578,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9853 first_binding >= nmaps) we don't want 9578 first_binding >= nmaps) we don't want
9854 to apply this function-key-mapping. */ 9579 to apply this function-key-mapping. */
9855 fkey.end + 1 == t 9580 fkey.end + 1 == t
9856 && (first_binding >= nmaps 9581 && (test_undefined (current_binding)),
9857 || test_undefined (defs[first_binding])),
9858 &diff, prompt); 9582 &diff, prompt);
9859 UNGCPRO; 9583 UNGCPRO;
9860 if (done) 9584 if (done)
@@ -9897,7 +9621,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9897 and cannot be part of a function key or translation, 9621 and cannot be part of a function key or translation,
9898 and is an upper case letter 9622 and is an upper case letter
9899 use the corresponding lower-case letter instead. */ 9623 use the corresponding lower-case letter instead. */
9900 if (first_binding >= nmaps 9624 if (NILP (current_binding)
9901 && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t 9625 && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t
9902 && INTEGERP (key) 9626 && INTEGERP (key)
9903 && ((CHARACTERP (make_number (XINT (key) & ~CHAR_MODIFIER_MASK)) 9627 && ((CHARACTERP (make_number (XINT (key) & ~CHAR_MODIFIER_MASK))
@@ -9928,7 +9652,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9928 and cannot be part of a function key or translation, 9652 and cannot be part of a function key or translation,
9929 and is a shifted function key, 9653 and is a shifted function key,
9930 use the corresponding unshifted function key instead. */ 9654 use the corresponding unshifted function key instead. */
9931 if (first_binding >= nmaps 9655 if (NILP (current_binding)
9932 && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t) 9656 && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t)
9933 { 9657 {
9934 Lisp_Object breakdown = parse_modifiers (key); 9658 Lisp_Object breakdown = parse_modifiers (key);
@@ -9969,9 +9693,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9969 } 9693 }
9970 } 9694 }
9971 if (!dummyflag) 9695 if (!dummyflag)
9972 read_key_sequence_cmd = (first_binding < nmaps 9696 read_key_sequence_cmd = current_binding;
9973 ? defs[first_binding]
9974 : Qnil);
9975 read_key_sequence_remapped 9697 read_key_sequence_remapped
9976 /* Remap command through active keymaps. 9698 /* Remap command through active keymaps.
9977 Do the remapping here, before the unbind_to so it uses the keymaps 9699 Do the remapping here, before the unbind_to so it uses the keymaps
@@ -9985,7 +9707,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9985 9707
9986 /* Don't downcase the last character if the caller says don't. 9708 /* Don't downcase the last character if the caller says don't.
9987 Don't downcase it if the result is undefined, either. */ 9709 Don't downcase it if the result is undefined, either. */
9988 if ((dont_downcase_last || first_binding >= nmaps) 9710 if ((dont_downcase_last || NILP (current_binding))
9989 && t > 0 9711 && t > 0
9990 && t - 1 == original_uppercase_position) 9712 && t - 1 == original_uppercase_position)
9991 { 9713 {
@@ -10082,7 +9804,7 @@ will read just one key sequence. */)
10082 9804
10083 memset (keybuf, 0, sizeof keybuf); 9805 memset (keybuf, 0, sizeof keybuf);
10084 GCPRO1 (keybuf[0]); 9806 GCPRO1 (keybuf[0]);
10085 gcpro1.nvars = (sizeof keybuf/sizeof (keybuf[0])); 9807 gcpro1.nvars = (sizeof keybuf / sizeof (keybuf[0]));
10086 9808
10087 if (NILP (continue_echo)) 9809 if (NILP (continue_echo))
10088 { 9810 {
@@ -11692,10 +11414,6 @@ This variable is also the threshold for motion of the mouse
11692to count as a drag. */); 11414to count as a drag. */);
11693 double_click_fuzz = 3; 11415 double_click_fuzz = 3;
11694 11416
11695 DEFVAR_BOOL ("inhibit-local-menu-bar-menus", inhibit_local_menu_bar_menus,
11696 doc: /* Non-nil means inhibit local map menu bar menus. */);
11697 inhibit_local_menu_bar_menus = 0;
11698
11699 DEFVAR_INT ("num-input-keys", num_input_keys, 11417 DEFVAR_INT ("num-input-keys", num_input_keys,
11700 doc: /* Number of complete key sequences read as input so far. 11418 doc: /* Number of complete key sequences read as input so far.
11701This includes key sequences read from keyboard macros. 11419This includes key sequences read from keyboard macros.
diff --git a/src/keyboard.h b/src/keyboard.h
index 7ffb436754b..c6ade35dd52 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -482,7 +482,7 @@ struct input_event;
482 482
483extern Lisp_Object parse_modifiers (Lisp_Object); 483extern Lisp_Object parse_modifiers (Lisp_Object);
484extern Lisp_Object reorder_modifiers (Lisp_Object); 484extern Lisp_Object reorder_modifiers (Lisp_Object);
485extern Lisp_Object read_char (int, ptrdiff_t, Lisp_Object *, Lisp_Object, 485extern Lisp_Object read_char (int, Lisp_Object, Lisp_Object,
486 bool *, EMACS_TIME *); 486 bool *, EMACS_TIME *);
487extern int parse_solitary_modifier (Lisp_Object symbol); 487extern int parse_solitary_modifier (Lisp_Object symbol);
488 488
diff --git a/src/keymap.c b/src/keymap.c
index 1e201e06dc3..922c1703edf 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1244,7 +1244,7 @@ remapping in all currently active keymaps. */)
1244 return INTEGERP (command) ? Qnil : command; 1244 return INTEGERP (command) ? Qnil : command;
1245} 1245}
1246 1246
1247/* Value is number if KEY is too long; nil if valid but has no definition. */ 1247/* Value is number if KEY is too long; nil if valid but has no definition. */
1248/* GC is possible in this function. */ 1248/* GC is possible in this function. */
1249 1249
1250DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0, 1250DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0,
@@ -1536,7 +1536,7 @@ DEFUN ("current-active-maps", Fcurrent_active_maps, Scurrent_active_maps,
1536 doc: /* Return a list of the currently active keymaps. 1536 doc: /* Return a list of the currently active keymaps.
1537OLP if non-nil indicates that we should obey `overriding-local-map' and 1537OLP if non-nil indicates that we should obey `overriding-local-map' and
1538`overriding-terminal-local-map'. POSITION can specify a click position 1538`overriding-terminal-local-map'. POSITION can specify a click position
1539like in the respective argument of `key-binding'. */) 1539like in the respective argument of `key-binding'. */)
1540 (Lisp_Object olp, Lisp_Object position) 1540 (Lisp_Object olp, Lisp_Object position)
1541{ 1541{
1542 ptrdiff_t count = SPECPDL_INDEX (); 1542 ptrdiff_t count = SPECPDL_INDEX ();
@@ -1545,7 +1545,7 @@ like in the respective argument of `key-binding'. */)
1545 1545
1546 /* If a mouse click position is given, our variables are based on 1546 /* If a mouse click position is given, our variables are based on
1547 the buffer clicked on, not the current buffer. So we may have to 1547 the buffer clicked on, not the current buffer. So we may have to
1548 switch the buffer here. */ 1548 switch the buffer here. */
1549 1549
1550 if (CONSP (position)) 1550 if (CONSP (position))
1551 { 1551 {
diff --git a/src/lread.c b/src/lread.c
index c62c62a5e5a..e7af86aa664 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -614,17 +614,17 @@ read_filtered_event (bool no_switch_frame, bool ascii_required,
614 end_time = add_emacs_time (current_emacs_time (), wait_time); 614 end_time = add_emacs_time (current_emacs_time (), wait_time);
615 } 615 }
616 616
617/* Read until we get an acceptable event. */ 617 /* Read until we get an acceptable event. */
618 retry: 618 retry:
619 do 619 do
620 val = read_char (0, 0, 0, (input_method ? Qnil : Qt), 0, 620 val = read_char (0, Qnil, (input_method ? Qnil : Qt), 0,
621 NUMBERP (seconds) ? &end_time : NULL); 621 NUMBERP (seconds) ? &end_time : NULL);
622 while (INTEGERP (val) && XINT (val) == -2); /* wrong_kboard_jmpbuf */ 622 while (INTEGERP (val) && XINT (val) == -2); /* wrong_kboard_jmpbuf */
623 623
624 if (BUFFERP (val)) 624 if (BUFFERP (val))
625 goto retry; 625 goto retry;
626 626
627 /* switch-frame events are put off until after the next ASCII 627 /* `switch-frame' events are put off until after the next ASCII
628 character. This is better than signaling an error just because 628 character. This is better than signaling an error just because
629 the last characters were typed to a separate minibuffer frame, 629 the last characters were typed to a separate minibuffer frame,
630 for example. Eventually, some code which can deal with 630 for example. Eventually, some code which can deal with
diff --git a/src/marker.c b/src/marker.c
index a03a0b104ca..0d992c0abfa 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -499,11 +499,29 @@ set_marker_internal (Lisp_Object marker, Lisp_Object position,
499 { 499 {
500 register ptrdiff_t charpos, bytepos; 500 register ptrdiff_t charpos, bytepos;
501 501
502 CHECK_NUMBER_COERCE_MARKER (position); 502 /* Do not use CHECK_NUMBER_COERCE_MARKER because we
503 charpos = clip_to_bounds (restricted ? BUF_BEGV (b) : BUF_BEG (b), 503 don't want to call buf_charpos_to_bytepos if POSTION
504 XINT (position), 504 is a marker and so we know the bytepos already. */
505 restricted ? BUF_ZV (b) : BUF_Z (b)); 505 if (INTEGERP (position))
506 bytepos = buf_charpos_to_bytepos (b, charpos); 506 charpos = XINT (position), bytepos = -1;
507 else if (MARKERP (position))
508 {
509 charpos = XMARKER (position)->charpos;
510 bytepos = XMARKER (position)->bytepos;
511 }
512 else
513 wrong_type_argument (Qinteger_or_marker_p, position);
514
515 charpos = clip_to_bounds
516 (restricted ? BUF_BEGV (b) : BUF_BEG (b), charpos,
517 restricted ? BUF_ZV (b) : BUF_Z (b));
518 if (bytepos == -1)
519 bytepos = buf_charpos_to_bytepos (b, charpos);
520 else
521 bytepos = clip_to_bounds
522 (restricted ? BUF_BEGV_BYTE (b) : BUF_BEG_BYTE (b),
523 bytepos, restricted ? BUF_ZV_BYTE (b) : BUF_Z_BYTE (b));
524
507 attach_marker (m, b, charpos, bytepos); 525 attach_marker (m, b, charpos, bytepos);
508 } 526 }
509 return marker; 527 return marker;
diff --git a/src/window.c b/src/window.c
index 68dcf28f52f..587ed8365c6 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1545,7 +1545,7 @@ Return POS. */)
1545{ 1545{
1546 register struct window *w = decode_live_window (window); 1546 register struct window *w = decode_live_window (window);
1547 1547
1548 CHECK_NUMBER_COERCE_MARKER (pos); 1548 /* Type of POS is checked by Fgoto_char or set_marker_restricted ... */
1549 1549
1550 if (w == XWINDOW (selected_window)) 1550 if (w == XWINDOW (selected_window))
1551 { 1551 {
@@ -1555,6 +1555,8 @@ Return POS. */)
1555 { 1555 {
1556 struct buffer *old_buffer = current_buffer; 1556 struct buffer *old_buffer = current_buffer;
1557 1557
1558 /* ... but here we want to catch type error before buffer change. */
1559 CHECK_NUMBER_COERCE_MARKER (pos);
1558 set_buffer_internal (XBUFFER (w->buffer)); 1560 set_buffer_internal (XBUFFER (w->buffer));
1559 Fgoto_char (pos); 1561 Fgoto_char (pos);
1560 set_buffer_internal (old_buffer); 1562 set_buffer_internal (old_buffer);
@@ -1580,9 +1582,8 @@ overriding motion of point in order to display at this exact start. */)
1580{ 1582{
1581 register struct window *w = decode_live_window (window); 1583 register struct window *w = decode_live_window (window);
1582 1584
1583 CHECK_NUMBER_COERCE_MARKER (pos);
1584 set_marker_restricted (w->start, pos, w->buffer); 1585 set_marker_restricted (w->start, pos, w->buffer);
1585 /* this is not right, but much easier than doing what is right. */ 1586 /* This is not right, but much easier than doing what is right. */
1586 w->start_at_line_beg = 0; 1587 w->start_at_line_beg = 0;
1587 if (NILP (noforce)) 1588 if (NILP (noforce))
1588 w->force_start = 1; 1589 w->force_start = 1;
@@ -4619,8 +4620,8 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4619 } 4620 }
4620 4621
4621 /* Set the window start, and set up the window for redisplay. */ 4622 /* Set the window start, and set up the window for redisplay. */
4622 set_marker_restricted (w->start, make_number (pos), 4623 set_marker_restricted_both (w->start, w->buffer, IT_CHARPOS (it),
4623 w->buffer); 4624 IT_BYTEPOS (it));
4624 bytepos = marker_byte_position (w->start); 4625 bytepos = marker_byte_position (w->start);
4625 w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); 4626 w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n');
4626 w->update_mode_line = 1; 4627 w->update_mode_line = 1;
@@ -5799,8 +5800,7 @@ the return value is nil. Otherwise the value is t. */)
5799 { 5800 {
5800 /* Set window markers at start of visible range. */ 5801 /* Set window markers at start of visible range. */
5801 if (XMARKER (w->start)->buffer == 0) 5802 if (XMARKER (w->start)->buffer == 0)
5802 set_marker_restricted (w->start, make_number (0), 5803 set_marker_restricted_both (w->start, w->buffer, 0, 0);
5803 w->buffer);
5804 if (XMARKER (w->pointm)->buffer == 0) 5804 if (XMARKER (w->pointm)->buffer == 0)
5805 set_marker_restricted_both 5805 set_marker_restricted_both
5806 (w->pointm, w->buffer, 5806 (w->pointm, w->buffer,
@@ -5818,10 +5818,8 @@ the return value is nil. Otherwise the value is t. */)
5818 wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); 5818 wset_buffer (w, other_buffer_safely (Fcurrent_buffer ()));
5819 /* This will set the markers to beginning of visible 5819 /* This will set the markers to beginning of visible
5820 range. */ 5820 range. */
5821 set_marker_restricted (w->start, 5821 set_marker_restricted_both (w->start, w->buffer, 0, 0);
5822 make_number (0), w->buffer); 5822 set_marker_restricted_both (w->pointm, w->buffer, 0, 0);
5823 set_marker_restricted (w->pointm,
5824 make_number (0), w->buffer);
5825 w->start_at_line_beg = 1; 5823 w->start_at_line_beg = 1;
5826 if (!NILP (w->dedicated)) 5824 if (!NILP (w->dedicated))
5827 /* Record this window as dead. */ 5825 /* Record this window as dead. */
diff --git a/src/xdisp.c b/src/xdisp.c
index 5b2eb1e84c8..2e357a6e321 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -9057,7 +9057,10 @@ move_it_vertically_backward (struct it *it, int dy)
9057 9057
9058 /* Estimate how many newlines we must move back. */ 9058 /* Estimate how many newlines we must move back. */
9059 nlines = max (1, dy / FRAME_LINE_HEIGHT (it->f)); 9059 nlines = max (1, dy / FRAME_LINE_HEIGHT (it->f));
9060 pos_limit = max (start_pos - nlines * nchars_per_row, BEGV); 9060 if (it->line_wrap == TRUNCATE)
9061 pos_limit = BEGV;
9062 else
9063 pos_limit = max (start_pos - nlines * nchars_per_row, BEGV);
9061 9064
9062 /* Set the iterator's position that many lines back. But don't go 9065 /* Set the iterator's position that many lines back. But don't go
9063 back more than NLINES full screen lines -- this wins a day with 9066 back more than NLINES full screen lines -- this wins a day with
@@ -9307,7 +9310,10 @@ move_it_by_lines (struct it *it, ptrdiff_t dvpos)
9307 /* Go back -DVPOS buffer lines, but no farther than -DVPOS full 9310 /* Go back -DVPOS buffer lines, but no farther than -DVPOS full
9308 screen lines, and reseat the iterator there. */ 9311 screen lines, and reseat the iterator there. */
9309 start_charpos = IT_CHARPOS (*it); 9312 start_charpos = IT_CHARPOS (*it);
9310 pos_limit = max (start_charpos + dvpos * nchars_per_row, BEGV); 9313 if (it->line_wrap == TRUNCATE)
9314 pos_limit = BEGV;
9315 else
9316 pos_limit = max (start_charpos + dvpos * nchars_per_row, BEGV);
9311 for (i = -dvpos; i > 0 && IT_CHARPOS (*it) > pos_limit; --i) 9317 for (i = -dvpos; i > 0 && IT_CHARPOS (*it) > pos_limit; --i)
9312 back_to_previous_visible_line_start (it); 9318 back_to_previous_visible_line_start (it);
9313 reseat (it, it->current.pos, 1); 9319 reseat (it, it->current.pos, 1);
@@ -9450,11 +9456,11 @@ message_dolog (const char *m, ptrdiff_t nbytes, int nlflag, int multibyte)
9450 bset_undo_list (current_buffer, Qt); 9456 bset_undo_list (current_buffer, Qt);
9451 9457
9452 oldpoint = message_dolog_marker1; 9458 oldpoint = message_dolog_marker1;
9453 set_marker_restricted (oldpoint, make_number (PT), Qnil); 9459 set_marker_restricted_both (oldpoint, Qnil, PT, PT_BYTE);
9454 oldbegv = message_dolog_marker2; 9460 oldbegv = message_dolog_marker2;
9455 set_marker_restricted (oldbegv, make_number (BEGV), Qnil); 9461 set_marker_restricted_both (oldbegv, Qnil, BEGV, BEGV_BYTE);
9456 oldzv = message_dolog_marker3; 9462 oldzv = message_dolog_marker3;
9457 set_marker_restricted (oldzv, make_number (ZV), Qnil); 9463 set_marker_restricted_both (oldzv, Qnil, ZV, ZV_BYTE);
9458 GCPRO1 (old_deactivate_mark); 9464 GCPRO1 (old_deactivate_mark);
9459 9465
9460 if (PT == Z) 9466 if (PT == Z)