commit 173fd94c11655bde2edf4cd1ee983e025aa06a79 (HEAD, refs/remotes/origin/master) Author: Michael Albinus Date: Wed May 8 09:44:22 2019 +0200 Skip tramp-test10-write-region-file-precious-flag for Emacs < 27 * test/lisp/net/tramp-tests.el (tramp-test10-write-region-file-precious-flag): Skip for Emacs < 27. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index e35be0e312..cce4d4e289 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2271,10 +2271,13 @@ This checks also `file-name-as-directory', `file-name-directory', ;; Cleanup. (ignore-errors (delete-file tmp-name)))))) +;; The following test is inspired by Bug#35497. (ert-deftest tramp-test10-write-region-file-precious-flag () "Check that `file-precious-flag' is respected with Tramp in use." (skip-unless (tramp--test-enabled)) (skip-unless (tramp--test-sh-p)) + ;; The bug is fixed in Emacs 27.1. + (skip-unless (tramp--test-emacs27-p)) (let* ((tmp-name (tramp--test-make-temp-name)) written-files commit 21888a94648df813cef354a22b92be9b23673358 Author: Jonathan Tomer Date: Wed May 8 09:13:58 2019 +0200 Don't rewrite buffer contents after saving by rename (Bug#35497) * lisp/files.el (basic-save-buffer-2): Don't rewrite file contents after saving-by-renaming. (Bug#35497) * test/lisp/files-tests.el (files-tests-dont-rewrite-precious-files): * test/lisp/net/tramp-tests.el (tramp-test10-write-region-file-precious-flag): Regression tests for this change. diff --git a/lisp/files.el b/lisp/files.el index 518394fdcd..8477c227bc 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5258,7 +5258,7 @@ Before and after saving the buffer, this function runs (set-file-extended-attributes buffer-file-name (nth 1 setmodes))) (set-file-modes buffer-file-name - (logior (car setmodes) 128)))))) + (logior (car setmodes) 128))))) (let (success) (unwind-protect (progn @@ -5274,7 +5274,7 @@ Before and after saving the buffer, this function runs (and setmodes (not success) (progn (rename-file (nth 2 setmodes) buffer-file-name t) - (setq buffer-backed-up nil)))))) + (setq buffer-backed-up nil))))))) setmodes)) (declare-function diff-no-select "diff" diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index ae8ea41a79..fe2e958f1c 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1244,5 +1244,20 @@ See ." (executable-find (file-name-nondirectory tmpfile)))))) (delete-file tmpfile)))) +(ert-deftest files-tests-dont-rewrite-precious-files () + "Test that `file-precious-flag' forces files to be saved by +renaming only, rather than modified in-place." + (let* ((temp-file-name (make-temp-file "files-tests")) + (advice (lambda (_start _end filename &rest _r) + (should-not (string= filename temp-file-name))))) + (unwind-protect + (with-current-buffer (find-file-noselect temp-file-name) + (advice-add #'write-region :before advice) + (setq-local file-precious-flag t) + (insert "foobar") + (should (null (save-buffer)))) + (ignore-errors (advice-remove #'write-region advice)) + (ignore-errors (delete-file temp-file-name))))) + (provide 'files-tests) ;;; files-tests.el ends here diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 7d3c43408d..e35be0e312 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -41,6 +41,7 @@ ;;; Code: +(require 'cl-seq) (require 'dired) (require 'ert) (require 'ert-x) @@ -2270,6 +2271,34 @@ This checks also `file-name-as-directory', `file-name-directory', ;; Cleanup. (ignore-errors (delete-file tmp-name)))))) +(ert-deftest tramp-test10-write-region-file-precious-flag () + "Check that `file-precious-flag' is respected with Tramp in use." + (skip-unless (tramp--test-enabled)) + (skip-unless (tramp--test-sh-p)) + + (let* ((tmp-name (tramp--test-make-temp-name)) + written-files + (advice (lambda (_start _end filename &rest _r) + (push filename written-files)))) + + (unwind-protect + (with-current-buffer (find-file-noselect tmp-name) + ;; Write initial contents. Adapt `visited-file-modtime' + ;; in order to suppress confirmation. + (insert "foo") + (write-region nil nil tmp-name) + (set-visited-file-modtime) + ;; Run the test. + (advice-add 'write-region :before advice) + (setq-local file-precious-flag t) + (insert "bar") + (should (null (save-buffer))) + (should-not (cl-member tmp-name written-files :test #'string=))) + + ;; Cleanup. + (ignore-errors (advice-remove 'write-region advice)) + (ignore-errors (delete-file tmp-name))))) + (ert-deftest tramp-test11-copy-file () "Check `copy-file'." (skip-unless (tramp--test-enabled)) commit cd8a1d6bfdc5aebc34348801dbaca06f2f4986c5 Author: Eli Zaretskii Date: Wed May 8 09:29:20 2019 +0300 Add an assertion to xdisp.c * src/xdisp.c (display_mode_element): Add an assertion where we assume that 'string' returned by decode_mode_spec is always either a Lisp string or nil. diff --git a/src/xdisp.c b/src/xdisp.c index 63ca677e36..d380645c84 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -24026,6 +24026,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision, ? string_byte_to_char (elt, bytepos) : bytepos); spec = decode_mode_spec (it->w, c, field, &string); + eassert (NILP (string) || STRINGP (string)); multibyte = !NILP (string) && STRING_MULTIBYTE (string); switch (mode_line_target) commit 4cb64ac3f9468422b471d9cc4c8edbc92fab6722 Author: Juri Linkov Date: Tue May 7 23:29:14 2019 +0300 * lisp/progmodes/flymake.el: Obsolete variable flymake-start-on-newline (flymake-start-syntax-check-on-newline): Mark it obsolete. (flymake-after-change-function): Remove obsolete variable flymake-start-syntax-check-on-newline (temporarily renamed to flymake-start-on-newline). (Bug#34294) * doc/misc/flymake.texi: Remove obsolete variable. diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi index 4608d1c973..ebb89c3203 100644 --- a/doc/misc/flymake.texi +++ b/doc/misc/flymake.texi @@ -87,10 +87,6 @@ Syntax check is done ``on-the-fly''. It is started whenever the buffer is saved, unless @code{flymake-start-on-save-buffer} is nil; -@item -a newline character is added to the buffer, unless -@code{flymake-start-on-newline} is nil; - @item some changes were made to the buffer more than @code{0.5} seconds ago (the delay is configurable in @code{flymake-no-changes-timeout}). @@ -222,10 +218,6 @@ If any changes are made to the buffer, syntax check is automatically started after this many seconds, unless the user makes another change, which resets the timer. -@item flymake-start-on-newline -A boolean flag indicating whether to start syntax check immediately -after a newline character is inserted into the buffer. - @item flymake-start-on-flymake-mode A boolean flag indicating whether to start syntax check immediately after enabling @code{flymake-mode}. diff --git a/etc/NEWS b/etc/NEWS index 72f669a4a4..d10a553244 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -329,7 +329,7 @@ and directory-local variables. a message about the error locus. --- -** New variable 'grep-search-path defines' the directories searched for +** New variable 'grep-search-path' defines the directories searched for grep hits (this used to be controlled by 'compilation-search-path'). --- @@ -706,8 +706,8 @@ This enables more efficient backends. See the docstring of 'flymake-diagnostic-functions' or the Flymake manual for details. +++ -*** The variable 'flymake-start-syntax-check-on-newline' is obsolete -and renamed to 'flymake-start-on-newline'. +*** 'flymake-start-syntax-check-on-newline' is now obsolete, +use 'post-self-insert-hook' to check on newline. ** Ruby diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index abe2933c10..4bb657e953 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -38,9 +38,9 @@ ;; The main interactive entry point is the `flymake-mode' minor mode, ;; which periodically and automatically initiates checks as the user ;; is editing the buffer. The variables `flymake-no-changes-timeout', -;; `flymake-start-on-newline' and `flymake-start-on-flymake-mode' -;; give finer control over the events triggering a check, as does the -;; interactive command `flymake-start', which immediately starts a check. +;; `flymake-start-on-flymake-mode' give finer control over the events +;; triggering a check, as does the interactive command `flymake-start', +;; which immediately starts a check. ;; ;; Shortly after each check, a summary of collected diagnostics should ;; appear in the mode-line. If it doesn't, there might not be a @@ -177,17 +177,13 @@ See `flymake-error-bitmap' and `flymake-warning-bitmap'." (const right-fringe) (const :tag "No fringe indicators" nil))) -(define-obsolete-variable-alias 'flymake-start-syntax-check-on-newline - 'flymake-start-on-newline "27.1") - -(defcustom flymake-start-on-newline t - "Start syntax check if newline char was added/removed from the buffer." - :type 'boolean) +(make-obsolete-variable 'flymake-start-syntax-check-on-newline + "can check on newline in post-self-insert-hook" + "27.1") (defcustom flymake-no-changes-timeout 0.5 "Time to wait after last change before automatically checking buffer. -If nil, never start checking buffer automatically like this. -You may also want to disable `flymake-start-on-newline'." +If nil, never start checking buffer automatically like this." :type '(choice (number :tag "Timeout in seconds") (const :tag "No check on timeout" nil))) @@ -947,9 +943,8 @@ results. Flymake performs these checks while the user is editing. The customization variables `flymake-start-on-flymake-mode', -`flymake-no-changes-timeout' and `flymake-start-on-newline' -determine the exact circumstances whereupon Flymake decides -to initiate a check of the buffer. +`flymake-no-changes-timeout' determine the exact circumstances +whereupon Flymake decides to initiate a check of the buffer. The commands `flymake-goto-next-error' and `flymake-goto-prev-error' can be used to navigate among Flymake @@ -1043,9 +1038,6 @@ Do it only if `flymake-no-changes-timeout' is non-nil." START and STOP and LEN are as in `after-change-functions'." (let((new-text (buffer-substring start stop))) (push (list start stop new-text) flymake--recent-changes) - (when (and flymake-start-on-newline (equal new-text "\n")) - (flymake-log :debug "starting syntax check as new-line has been seen") - (flymake-start t)) (flymake--schedule-timer-maybe))) (defun flymake-after-save-hook () commit 504f8e551f88b5d58cf3d2dc3c12df273b6d972c Author: Paul Eggert Date: Tue May 7 12:26:40 2019 -0700 Pacify GCC 9.1 * src/intervals.c (set_intervals_multibyte_1): Omit unused temps. * src/xdisp.c (display_mode_element): Use !NILP instead of STRINGP. This convinces GCC we’re not dereferencing a possibly-null pointer, and should be a bit faster anyway. diff --git a/src/intervals.c b/src/intervals.c index 34829ab050..38367460a5 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -2334,7 +2334,6 @@ set_intervals_multibyte_1 (INTERVAL i, bool multi_flag, if (multi_flag) { - ptrdiff_t temp; left_end_byte = advance_to_char_boundary (start_byte + LEFT_TOTAL_LENGTH (i)); left_end = BYTE_TO_CHAR (left_end_byte); @@ -2355,8 +2354,6 @@ set_intervals_multibyte_1 (INTERVAL i, bool multi_flag, if (multi_flag) { - ptrdiff_t temp; - right_start_byte = advance_to_char_boundary (end_byte - RIGHT_TOTAL_LENGTH (i)); right_start = BYTE_TO_CHAR (right_start_byte); diff --git a/src/xdisp.c b/src/xdisp.c index a8604d58af..63ca677e36 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -24026,7 +24026,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision, ? string_byte_to_char (elt, bytepos) : bytepos); spec = decode_mode_spec (it->w, c, field, &string); - multibyte = STRINGP (string) && STRING_MULTIBYTE (string); + multibyte = !NILP (string) && STRING_MULTIBYTE (string); switch (mode_line_target) { @@ -24702,8 +24702,9 @@ percent99 (ptrdiff_t n, ptrdiff_t d) /* Return a string for the output of a mode line %-spec for window W, generated by character C. FIELD_WIDTH > 0 means pad the string - returned with spaces to that value. Return a Lisp string in - *STRING if the resulting string is taken from that Lisp string. + returned with spaces to that value. Set *STRING to be a Lisp + string if the resulting string is taken from that Lisp string; + otherwise, set *STRING to Qnil. Note we operate on the current buffer for most purposes. */ commit e44b56d16ad0749e599700a73509c16391ed973e Author: John Shahid Date: Mon Apr 29 13:53:38 2019 -0400 Fix setting and resetting of scroll-with-delete The start and end lines of the scroll region must to be in the range [0,term-height). There are few placees that incorrectly set the end line of the scroll region to term-height which is outside the valid range. Combined with another off-by-one error in term-set-scroll-region's clamping logic, this would cause term-scroll-with-delete to be unnecessarily turned on. * lisp/term.el (term-scroll-start,term-scroll-end): Use defvar-local to define the variables and document the valid range of values that the variables can take. (term--last-line): New function to calculate the 0-based index of the last line. (term--reset-scroll-region): New function to reset the scroll region to the full height of the terminal. (term-mode,term-reset-size,term-reset-terminal): Call term--reset-scroll-region to reset the scroll region. (term-set-scroll-region): Fix the off-by-one error in the clamping logic which allowed term-scroll-end to have values outside the valid range [0,term-height). diff --git a/lisp/term.el b/lisp/term.el index 283e5684b7..553c3a1af4 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -390,8 +390,16 @@ This emulates (more or less) the behavior of xterm.") "A queue of strings whose echo we want suppressed.") (defvar term-terminal-undecoded-bytes nil) (defvar term-current-face 'term) -(defvar term-scroll-start 0 "Top-most line (inclusive) of scrolling region.") -(defvar term-scroll-end) ; Number of line (zero-based) after scrolling region. +(defvar-local term-scroll-start 0 + "Top-most line (inclusive) of the scrolling region. +`term-scroll-start' must be in the range [0,term-height). In addition, its +value has to be smaller than `term-scroll-end', i.e. one line scroll regions are +not allowed.") +(defvar-local term-scroll-end nil + "Bottom-most line (inclusive) of the scrolling region. +`term-scroll-end' must be in the range [0,term-height). In addition, its +value has to be greater than `term-scroll-start', i.e. one line scroll regions are +not allowed.") (defvar term-pager-count nil "Number of lines before we need to page; if nil, paging is disabled.") (defvar term-saved-cursor nil) @@ -1075,9 +1083,6 @@ Entry to this mode runs the hooks on `term-mode-hook'." (make-local-variable 'term-current-column) (make-local-variable 'term-current-row) (make-local-variable 'term-log-buffer) - (make-local-variable 'term-scroll-start) - (set (make-local-variable 'term-scroll-end) term-height) - (make-local-variable 'term-scroll-with-delete) (make-local-variable 'term-pager-count) (make-local-variable 'term-pager-old-local-map) (make-local-variable 'term-old-mode-map) @@ -1117,6 +1122,8 @@ Entry to this mode runs the hooks on `term-mode-hook'." (add-hook 'read-only-mode-hook #'term-line-mode-buffer-read-only-update nil t) + (term--reset-scroll-region) + (easy-menu-add term-terminal-menu) (easy-menu-add term-signals-menu) (or term-input-ring @@ -1133,6 +1140,9 @@ Entry to this mode runs the hooks on `term-mode-hook'." (let ((inhibit-read-only t)) (delete-char 1))))) +(defun term--last-line () + (1- term-height)) + (defun term--filter-buffer-substring (content) (with-temp-buffer (insert content) @@ -1174,7 +1184,7 @@ Entry to this mode runs the hooks on `term-mode-hook'." (setq term-start-line-column nil) (setq term-current-row nil) (setq term-current-column nil) - (term-set-scroll-region 0 height) + (term--reset-scroll-region) ;; `term-set-scroll-region' causes these to be set, we have to ;; clear them again since we're changing point (Bug#30544). (setq term-start-line-column nil) @@ -3205,7 +3215,7 @@ option is enabled. See `term-set-goto-process-mark'." (goto-char term-home-marker) (term-vertical-motion (1+ count)) (set-marker term-home-marker (point)) - (setq term-current-row (1- term-height)))))) + (setq term-current-row (term--last-line)))))) (defun term-reset-terminal () "Reset the terminal, delete all the content and set the face to the default one." @@ -3213,8 +3223,7 @@ option is enabled. See `term-set-goto-process-mark'." (term-ansi-reset) (setq term-current-row 0) (setq term-current-column 1) - (setq term-scroll-start 0) - (setq term-scroll-end term-height) + (term--reset-scroll-region) (setq term-insert-mode nil) ;; FIXME: No idea why this is here, it looks wrong. --Stef (setq term-ansi-face-already-done nil)) @@ -3423,6 +3432,10 @@ option is enabled. See `term-set-goto-process-mark'." (1- (or (nth 1 params) 0)))) (t))) +(defun term--reset-scroll-region () + "Sets the scroll region to the full height of the terminal." + (term-set-scroll-region 0 (term--last-line))) + (defun term-set-scroll-region (top bottom) "Set scrolling region. TOP is the top-most line (inclusive) of the new scrolling region, @@ -3433,13 +3446,13 @@ The top-most line is line 0." 0 top)) (setq term-scroll-end - (if (or (<= bottom term-scroll-start) (> bottom term-height)) - term-height + (if (or (<= bottom term-scroll-start) (> bottom (term--last-line))) + (term--last-line) bottom)) (setq term-scroll-with-delete (or (term-using-alternate-sub-buffer) (not (and (= term-scroll-start 0) - (= term-scroll-end term-height))))) + (= term-scroll-end (term--last-line)))))) (term-move-columns (- (term-current-column))) (term-goto 0 0)) @@ -3568,7 +3581,7 @@ The top-most line is line 0." (when (> moved lines) (backward-char)) (cond ((<= deficit 0) ;; OK, had enough in the buffer for request. - (recenter (1- term-height))) + (recenter (term--last-line))) ((term-pager-continue deficit))))) (defun term-pager-page (arg) @@ -3582,7 +3595,7 @@ The top-most line is line 0." (goto-char (point-min)) (when (= (vertical-motion term-height) term-height) (backward-char)) - (recenter (1- term-height))) + (recenter (term--last-line))) ;; Pager mode command to go to end of buffer. (defun term-pager-eob () @@ -3600,7 +3613,7 @@ The top-most line is line 0." ;; Move cursor to end of window. (vertical-motion term-height) (backward-char)) - (recenter (1- term-height))) + (recenter (term--last-line))) (defun term-pager-back-page (arg) (interactive "p") diff --git a/test/lisp/term-tests.el b/test/lisp/term-tests.el index 9f5dcd559e..6923096d22 100644 --- a/test/lisp/term-tests.el +++ b/test/lisp/term-tests.el @@ -119,7 +119,141 @@ line3\r line4\r line5\r line6\r -")))) +"))) + + ;; test reverse scrolling + (should (equal "line1 +line7 +line6 +line2 +line5" + (term-test-screen-from-input 40 5 + '("\e[0;0H" + "\e[J" + "line1\r +line2\r +line3\r +line4\r +line5" + "\e[2;4r" + "\e[2;0H" + "\e[2;0H" + "\eMline6" + "\e[2;0H" + "\eMline7")))) + + ;; test scrolling down + (should (equal "line1 +line3 +line4 +line7 +line5" + (term-test-screen-from-input 40 5 + '("\e[0;0H" + "\e[J" + "line1\r +line2\r +line3\r +line4\r +line5" + "\e[2;4r" + "\e[2;0H" + "\e[4;5H" + "\n\rline7")))) + + ;; setting the scroll region end beyond the max height should not + ;; turn on term-scroll-with-delete + (should (equal "line1 +line2 +line3 +line4 +line5 +line6 +line7" + (term-test-screen-from-input 40 5 + '("\e[1;10r" + "line1\r +line2\r +line3\r +line4\r +line5\r +line6\r +line7")))) + + + ;; resetting the terminal should set the scroll region end to (1- term-height). + (should (equal " +line1 +line2 +line3 +line4 +" + (term-test-screen-from-input 40 5 + '("\e[1;10r" + "\ec" ;reset + "line1\r +line2\r +line3\r +line4\r +line5" + "\e[1;1H" + "\e[L")))) + + ;; scroll region should be limited to the (1- term-height). Note, + ;; this fixes an off by one error when comparing the scroll region + ;; end with term-height. + (should (equal " +line1 +line2 +line3 +line4 +" + (term-test-screen-from-input 40 5 + '("\e[1;6r" + "line1\r +line2\r +line3\r +line4\r +line5" + "\e[1;1H" ;go back to home + "\e[L" ;insert a new line at the top + )))) + + ;; setting the scroll region to the entire height should not turn on + ;; term-scroll-with-delete + (should (equal "line1 +line2 +line3 +line4 +line5 +line6" + (term-test-screen-from-input 40 5 + '("\e[1;5r" + "line1\r +line2\r +line3\r +line4\r +line5\r +line6")))) + + ;; reset should reset term-scroll-with-delete + (should (equal "line1 +line2 +line3 +line4 +line5 +line6 +line7" + (term-test-screen-from-input 40 5 + '("\e[2;5r" ;set the region + "\ec" ;reset + "line1\r +line2\r +line3\r +line4\r +line5\r +line6\r +line7"))))) (ert-deftest term-set-directory () (let ((term-ansi-at-user (user-real-login-name))) commit 32cf07819ae8cfdbf14e00f351c7f520fff325c3 Author: Stefan Monnier Date: Tue May 7 13:41:54 2019 -0400 * src/marker.c (buf_bytepos_to_charpos): Re-add the CHAR_HEAD_P assertion This assertion was removed in 1c349c62305d432abf0fa2b6e3f5d754fe4cab79 because the assumption was invalid during set_intervals_multibyte_1. So we change set_intervals_multibyte_1 to solve the problem in the same way as in the rest of Fset_buffer_multibyte, which actually simplifies the code. * src/buffer.c (advance_to_char_boundary): Not static any more. * src/buffer.h (advance_to_char_boundary): Add prototype. * src/intervals.c (set_intervals_multibyte_1): Use it. diff --git a/src/buffer.c b/src/buffer.c index ab47748191..3b5078a175 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2264,7 +2264,7 @@ validate_region (register Lisp_Object *b, register Lisp_Object *e) /* Advance BYTE_POS up to a character boundary and return the adjusted position. */ -static ptrdiff_t +ptrdiff_t advance_to_char_boundary (ptrdiff_t byte_pos) { int c; @@ -2702,6 +2702,9 @@ current buffer is cleared. */) /* Do this last, so it can calculate the new correspondences between chars and bytes. */ + /* FIXME: Is it worth the trouble, really? Couldn't we just throw + away all the text-properties instead of trying to guess how + to adjust them? AFAICT the result is not reliable anyway. */ set_intervals_multibyte (1); } diff --git a/src/buffer.h b/src/buffer.h index f42c3e97b9..2080a6f40b 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -327,6 +327,10 @@ extern void enlarge_buffer_text (struct buffer *, ptrdiff_t); #define BYTE_TO_CHAR(bytepos) \ (buf_bytepos_to_charpos (current_buffer, bytepos)) +/* For those very rare cases where you may have a "random" pointer into + the middle of a multibyte char, this moves to the next boundary. */ +extern ptrdiff_t advance_to_char_boundary (ptrdiff_t byte_pos); + /* Convert PTR, the address of a byte in the buffer, into a byte position. */ #define PTR_BYTE_POS(ptr) \ diff --git a/src/intervals.c b/src/intervals.c index 8f39c45762..34829ab050 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -2335,22 +2335,10 @@ set_intervals_multibyte_1 (INTERVAL i, bool multi_flag, if (multi_flag) { ptrdiff_t temp; - left_end_byte = start_byte + LEFT_TOTAL_LENGTH (i); + left_end_byte + = advance_to_char_boundary (start_byte + LEFT_TOTAL_LENGTH (i)); left_end = BYTE_TO_CHAR (left_end_byte); - - temp = CHAR_TO_BYTE (left_end); - - /* If LEFT_END_BYTE is in the middle of a character, - adjust it and LEFT_END to a char boundary. */ - if (left_end_byte > temp) - { - left_end_byte = temp; - } - if (left_end_byte < temp) - { - left_end--; - left_end_byte = CHAR_TO_BYTE (left_end); - } + eassert (CHAR_TO_BYTE (left_end) == left_end_byte); } else { @@ -2369,22 +2357,10 @@ set_intervals_multibyte_1 (INTERVAL i, bool multi_flag, { ptrdiff_t temp; - right_start_byte = end_byte - RIGHT_TOTAL_LENGTH (i); + right_start_byte + = advance_to_char_boundary (end_byte - RIGHT_TOTAL_LENGTH (i)); right_start = BYTE_TO_CHAR (right_start_byte); - - /* If RIGHT_START_BYTE is in the middle of a character, - adjust it and RIGHT_START to a char boundary. */ - temp = CHAR_TO_BYTE (right_start); - - if (right_start_byte < temp) - { - right_start_byte = temp; - } - if (right_start_byte > temp) - { - right_start++; - right_start_byte = CHAR_TO_BYTE (right_start); - } + eassert (CHAR_TO_BYTE (right_start) == right_start_byte); } else { diff --git a/src/marker.c b/src/marker.c index b58051a8c2..0b2e1bf5c6 100644 --- a/src/marker.c +++ b/src/marker.c @@ -332,6 +332,10 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos) if (best_above == best_above_byte) return bytepos; + /* Check bytepos is not in the middle of a character. */ + eassert (bytepos >= BUF_Z_BYTE (b) + || CHAR_HEAD_P (BUF_FETCH_BYTE (b, bytepos))); + best_below = BEG; best_below_byte = BEG_BYTE; commit 81d83cf6357c73ac5e8de8aeac9760ab00f5af0a Author: Glenn Morris Date: Tue May 7 10:33:36 2019 -0700 * doc/emacs/text.texi (Fill Commands): Use pxref in parentheses. diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi index df2f6c0006..7892b346d2 100644 --- a/doc/emacs/text.texi +++ b/doc/emacs/text.texi @@ -646,7 +646,7 @@ even if preceded by a non-whitespace character). Emacs can display an indicator in the @code{fill-column} position using the Display fill column indicator mode -(@xref{Displaying Boundaries, display-fill-column-indicator}). +(@pxref{Displaying Boundaries, display-fill-column-indicator}). @node Fill Prefix @subsection The Fill Prefix commit 6d03bbf02ad89e6a6a1534b8b1bdcb0fc6816bf4 Author: Glenn Morris Date: Tue May 7 10:32:03 2019 -0700 * doc/emacs/files.texi (Auto Revert): Fix makeinfo-4.13 compilation. diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index c51d076fa2..36ef1dcea2 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -1031,6 +1031,9 @@ under version control. @xref{VC Mode Line}, for Auto Revert peculiarities when visiting files under version control. @ifnottex +@menu +* Non-File Buffers:: Auto Reverting Non-File Buffers. +@end menu @include arevert-xtra.texi @end ifnottex commit c972da907d494b6d5efd423aa3b5d0b23f7b7801 Author: Basil L. Contovounesios Date: Sun Apr 21 23:02:01 2019 +0100 Clarify what constitutes an event (bug#35238) * doc/lispref/commands.texi (Input Events): Specify that events are non-nil and remove vestiges of bug#10190. * doc/lispref/os.texi (Recording Input): Document optional argument of recent-keys. * lisp/subr.el (eventp): Check that the car of conses is non-nil. * etc/NEWS: Announce it as an incompatible change. * src/keyboard.c (Frecent_keys): Clarify that returned "events" are not real events. diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index cd44c1c87e..5ea0be2667 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi @@ -1047,12 +1047,9 @@ and meaning of input events in detail. This function returns non-@code{nil} if @var{object} is an input event or event type. -Note that any symbol might be used as an event or an event type. -@code{eventp} cannot distinguish whether a symbol is intended by Lisp -code to be used as an event. Instead, it distinguishes whether the -symbol has actually been used in an event that has been read as input in -the current Emacs session. If a symbol has not yet been so used, -@code{eventp} returns @code{nil}. +Note that any non-@code{nil} symbol might be used as an event or an +event type; @code{eventp} cannot distinguish whether a symbol is +intended by Lisp code to be used as an event. @end defun @menu diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 59cd5a8fe8..fef954eb7a 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -2197,7 +2197,7 @@ is the character Emacs currently uses for quitting, usually @kbd{C-g}. @subsection Recording Input @cindex recording input -@defun recent-keys +@defun recent-keys &optional include-cmds This function returns a vector containing the last 300 input events from the keyboard or mouse. All input events are included, whether or not they were used as parts of key sequences. Thus, you always get the last @@ -2205,6 +2205,11 @@ they were used as parts of key sequences. Thus, you always get the last (These are excluded because they are less interesting for debugging; it should be enough to see the events that invoked the macros.) +If @var{include-cmds} is non-@code{nil}, complete key sequences in the +result vector are interleaved with pseudo-events of the form +@code{(nil . @var{COMMAND})}, where @var{COMMAND} is the binding of +the key sequence (@pxref{Command Overview}). + A call to @code{clear-this-command-keys} (@pxref{Command Loop Info}) causes this function to return an empty vector immediately afterward. @end defun diff --git a/etc/NEWS b/etc/NEWS index 5fe2e63526..72f669a4a4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1575,6 +1575,11 @@ performs '(setq-local indent-line-function #'indent-relative)'. ** 'make-process' no longer accepts a non-nil ':stop' key. This has never worked reliably, and now causes an error. ++++ +** 'eventp' no longer returns non-nil for lists whose car is nil. +This is consistent with the fact that nil, though a symbol, is not a +valid event type. + * Lisp Changes in Emacs 27.1 diff --git a/lisp/subr.el b/lisp/subr.el index f68f9dd419..be21dc67a0 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1238,12 +1238,14 @@ The normal global definition of the character C-x indirects to this keymap.") c))) key))) -(defun eventp (obj) - "True if the argument is an event object." - (when obj - (or (integerp obj) - (and (symbolp obj) obj (not (keywordp obj))) - (and (consp obj) (symbolp (car obj)))))) +(defun eventp (object) + "Return non-nil if OBJECT is an input event or event object." + (or (integerp object) + (and (if (consp object) + (setq object (car object)) + object) + (symbolp object) + (not (keywordp object))))) (defun event-modifiers (event) "Return a list of symbols representing the modifier keys in event EVENT. diff --git a/src/keyboard.c b/src/keyboard.c index ea13c7f5bc..5f2b7afe6d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -9968,7 +9968,7 @@ If CHECK-TIMERS is non-nil, timers that are ready to run will do so. */) DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 1, 0, doc: /* Return vector of last few events, not counting those from keyboard macros. If INCLUDE-CMDS is non-nil, include the commands that were run, -represented as events of the form (nil . COMMAND). */) +represented as pseudo-events of the form (nil . COMMAND). */) (Lisp_Object include_cmds) { bool cmds = !NILP (include_cmds); commit e10d08df7edbb2e9e90169d19c3361099802fad6 Author: Eli Zaretskii Date: Tue May 7 17:48:32 2019 +0300 Fix 'load-average' on MS-Windows * src/w32.c (getloadavg): Always return at least one element of the array. diff --git a/src/w32.c b/src/w32.c index 677c37fcb5..833ff4c7e4 100644 --- a/src/w32.c +++ b/src/w32.c @@ -2003,6 +2003,13 @@ getloadavg (double loadavg[], int nelem) loadavg[elem] = avg; } + /* Always return at least one element, otherwise load-average + returns nil, and Lisp programs might decide we cannot measure + system load. For example, jit-lock-stealth-load's defcustom + might decide that feature is "unsupported". */ + if (elem == 0) + loadavg[elem++] = 0.09; /* < display-time-load-average-threshold */ + return elem; }