commit 1827197e911414284b4935a2d71257401629930c (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Sun Mar 31 20:00:30 2019 -0700 Use update-game-score more often with Tetris * lisp/play/gamegrid.el (gamegrid-add-score-with-update-game-score): Go back to previous way of deciding whether to invoke update-game-score, except do not try to invoke it if file-modes fails on it (Bug#35056). diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el index 430a2071bf..4a9dac7f74 100644 --- a/lisp/play/gamegrid.el +++ b/lisp/play/gamegrid.el @@ -565,8 +565,8 @@ FILE is created there." ;; On POSIX systems there are four cases to distinguish: -;; 1. FILE is an absolute filename. Then it should be a file in -;; temporary file directory. This is the way, +;; 1. FILE is an absolute filename or "update-game-score" does not exist. +;; Then FILE should be a file in a temporary file directory. This is how ;; `gamegrid-add-score' was supposed to be used in the past and ;; is covered here for backward-compatibility. ;; @@ -583,21 +583,18 @@ FILE is created there." ;; update FILE. This is for the case that a user has installed ;; a game on her own. ;; -;; 4. "update-game-score" does not exist or is not setgid/setuid. -;; Create/update FILE in the user's home directory, without -;; using "update-game-score". There is presumably no shared -;; game directory. +;; 4. "update-game-score" is not setgid/setuid. Use it to +;; create/update FILE in the user's home directory. There is +;; presumably no shared game directory. (defvar gamegrid-shared-game-dir) (defun gamegrid-add-score-with-update-game-score (file score) - (let ((gamegrid-shared-game-dir - (not (zerop (logand (or (file-modes - (expand-file-name "update-game-score" - exec-directory)) - 0) - #o6000))))) - (cond ((file-name-absolute-p file) + (let* ((update-game-score-modes + (file-modes (expand-file-name "update-game-score" exec-directory))) + (gamegrid-shared-game-dir + (not (zerop (logand #o6000 (or update-game-score-modes 0)))))) + (cond ((or (not update-game-score-modes) (file-name-absolute-p file)) (gamegrid-add-score-insecure file score)) ((and gamegrid-shared-game-dir (file-exists-p (expand-file-name file shared-game-score-directory))) @@ -607,12 +604,23 @@ FILE is created there." (expand-file-name file shared-game-score-directory) score)) ;; Else: Add the score to a score file in the user's home ;; directory. - (t + (gamegrid-shared-game-dir + ;; If gamegrid-shared-game-dir is non-nil the + ;; "update-gamescore" program is setuid, so don't use it. (unless (file-exists-p (directory-file-name gamegrid-user-score-file-directory)) (make-directory gamegrid-user-score-file-directory t)) (gamegrid-add-score-insecure file score - gamegrid-user-score-file-directory))))) + gamegrid-user-score-file-directory)) + (t + (unless (file-exists-p + (directory-file-name gamegrid-user-score-file-directory)) + (make-directory gamegrid-user-score-file-directory t)) + (let ((f (expand-file-name file + gamegrid-user-score-file-directory))) + (unless (file-exists-p f) + (write-region "" nil f nil 'silent nil 'excl)) + (gamegrid-add-score-with-update-game-score-1 file f score)))))) (defun gamegrid-add-score-with-update-game-score-1 (file target score) (let ((default-directory "/") commit 63471c837dde50179f3c7bb6d316d61160e9e825 Author: Basil L. Contovounesios Date: Mon Mar 25 23:10:59 2019 +0000 Do not set indent-line-function in text-mode * lisp/textmodes/text-mode.el (text-mode): Do not reset indent-line-function to its global default value of indent-relative. * doc/lispref/modes.texi (Example Major Modes): * etc/NEWS: Document change accordingly. diff --git a/etc/NEWS b/etc/NEWS index 89e07a2f4d..836dd2bb1a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1233,6 +1233,11 @@ near the current column in Tabulated Lists (see variables 'tabulated-list-tty-sort-indicator-asc', and 'tabulated-list-tty-sort-indicator-desc'). +** Text mode + ++++ +*** 'text-mode-variant' is now obsolete, use 'derived-mode-p' instead. + * New Modes and Packages in Emacs 27.1 diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el index 6114490208..e676a5dae2 100644 --- a/lisp/textmodes/text-mode.el +++ b/lisp/textmodes/text-mode.el @@ -38,8 +38,8 @@ :group 'text) (defvar text-mode-variant nil - "Non-nil if this buffer's major mode is a variant of Text mode. -Use (derived-mode-p \\='text-mode) instead.") + "Non-nil if this buffer's major mode is a variant of Text mode.") +(make-obsolete-variable 'text-mode-variant 'derived-mode-p "27.1") (defvar text-mode-syntax-table (let ((st (make-syntax-table))) commit 2e3deb09bd42d22a9b354937ce63b151fb493d8a Author: Basil L. Contovounesios Date: Sun Mar 31 19:39:54 2019 +0100 Do not set indent-line-function in text-mode For discussion, see thread starting at: https://lists.gnu.org/archive/html/emacs-devel/2019-03/msg01012.html * lisp/textmodes/text-mode.el (text-mode): Do not reset indent-line-function to its global default value of indent-relative. * doc/lispref/modes.texi (Example Major Modes): * etc/NEWS: Document change accordingly. diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 7b64a56b19..4315b70ed7 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -1292,15 +1292,10 @@ Turning on Text mode runs the normal hook `text-mode-hook'." @end group @group (setq-local text-mode-variant t) - (setq-local require-final-newline mode-require-final-newline) - (setq-local indent-line-function #'indent-relative)) + (setq-local require-final-newline mode-require-final-newline)) @end group @end smallexample -@noindent -(The last line is redundant nowadays, since @code{indent-relative} is -the default value, and we'll delete it in a future version.) - @cindex @file{lisp-mode.el} The three Lisp modes (Lisp mode, Emacs Lisp mode, and Lisp Interaction mode) have more features than Text mode and the code is correspondingly diff --git a/etc/NEWS b/etc/NEWS index 7486d6bcfe..89e07a2f4d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1371,6 +1371,15 @@ ending character were silently omitted. For example, '(rx (any "@z-a" (?9 . ?0)))' would match '@' only. Now, such rx expressions generate an error. ++++ +** 'text-mode' no longer sets the value of 'indent-line-function'. +The global value of 'indent-line-function', which defaults to +'indent-relative', will no longer be reset locally when turning on +'text-mode'. + +To get back the old behavior, add a function to 'text-mode-hook' which +performs (setq-local indent-line-function #'indent-relative). + * Lisp Changes in Emacs 27.1 diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el index 90bb3eb3b5..6114490208 100644 --- a/lisp/textmodes/text-mode.el +++ b/lisp/textmodes/text-mode.el @@ -105,8 +105,7 @@ You can thus get the full benefit of adaptive filling \\{text-mode-map} Turning on Text mode runs the normal hook `text-mode-hook'." (setq-local text-mode-variant t) - (setq-local require-final-newline mode-require-final-newline) - (setq-local indent-line-function #'indent-relative)) + (setq-local require-final-newline mode-require-final-newline)) (define-derived-mode paragraph-indent-text-mode text-mode "Parindent" "Major mode for editing text, with leading spaces starting a paragraph. commit 4c9950d015fdb520d29f04c6b1eb7418a442fc60 Author: Basil L. Contovounesios Date: Mon Mar 18 23:45:55 2019 +0000 Use lexical-binding in text-mode.el * lisp/textmodes/text-mode.el: Use lexical-binding. (text-mode, paragraph-indent-minor-mode, text-mode-hook-identify): Use setq-local. (toggle-text-mode-auto-fill): Quote function symbols as such. (center-line): Minor simplification. * doc/lispref/modes.texi (Example Major Modes): Update code example for these changes to text-mode. diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 1afbc5a5ce..7b64a56b19 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -1291,10 +1291,9 @@ You can thus get the full benefit of adaptive filling Turning on Text mode runs the normal hook `text-mode-hook'." @end group @group - (set (make-local-variable 'text-mode-variant) t) - (set (make-local-variable 'require-final-newline) - mode-require-final-newline) - (set (make-local-variable 'indent-line-function) 'indent-relative)) + (setq-local text-mode-variant t) + (setq-local require-final-newline mode-require-final-newline) + (setq-local indent-line-function #'indent-relative)) @end group @end smallexample diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el index 931faadb5b..90bb3eb3b5 100644 --- a/lisp/textmodes/text-mode.el +++ b/lisp/textmodes/text-mode.el @@ -1,4 +1,4 @@ -;;; text-mode.el --- text mode, and its idiosyncratic commands +;;; text-mode.el --- text mode, and its idiosyncratic commands -*- lexical-binding: t -*- ;; Copyright (C) 1985, 1992, 1994, 2001-2019 Free Software Foundation, ;; Inc. @@ -104,10 +104,9 @@ You can thus get the full benefit of adaptive filling (see the variable `adaptive-fill-mode'). \\{text-mode-map} Turning on Text mode runs the normal hook `text-mode-hook'." - (set (make-local-variable 'text-mode-variant) t) - (set (make-local-variable 'require-final-newline) - mode-require-final-newline) - (set (make-local-variable 'indent-line-function) 'indent-relative)) + (setq-local text-mode-variant t) + (setq-local require-final-newline mode-require-final-newline) + (setq-local indent-line-function #'indent-relative)) (define-derived-mode paragraph-indent-text-mode text-mode "Parindent" "Major mode for editing text, with leading spaces starting a paragraph. @@ -131,14 +130,12 @@ Turning on Paragraph-Indent minor mode runs the normal hook :initial-value nil ;; Change the definition of a paragraph start. (let ((ps-re "[ \t\n\f]\\|")) - (if (eq t (compare-strings ps-re nil nil - paragraph-start nil (length ps-re))) + (if (string-prefix-p ps-re paragraph-start) (if (not paragraph-indent-minor-mode) - (set (make-local-variable 'paragraph-start) - (substring paragraph-start (length ps-re)))) + (setq-local paragraph-start + (substring paragraph-start (length ps-re)))) (if paragraph-indent-minor-mode - (set (make-local-variable 'paragraph-start) - (concat ps-re paragraph-start))))) + (setq-local paragraph-start (concat ps-re paragraph-start))))) ;; Change the indentation function. (if paragraph-indent-minor-mode (add-function :override (local 'indent-line-function) @@ -154,7 +151,7 @@ Turning on Paragraph-Indent minor mode runs the normal hook (defun text-mode-hook-identify () "Mark that this mode has run `text-mode-hook'. This is how `toggle-text-mode-auto-fill' knows which buffers to operate on." - (set (make-local-variable 'text-mode-variant) t)) + (setq-local text-mode-variant t)) (defun toggle-text-mode-auto-fill () "Toggle whether to use Auto Fill in Text mode and related modes. @@ -163,8 +160,8 @@ both existing buffers and buffers that you subsequently create." (interactive) (let ((enable-mode (not (memq 'turn-on-auto-fill text-mode-hook)))) (if enable-mode - (add-hook 'text-mode-hook 'turn-on-auto-fill) - (remove-hook 'text-mode-hook 'turn-on-auto-fill)) + (add-hook 'text-mode-hook #'turn-on-auto-fill) + (remove-hook 'text-mode-hook #'turn-on-auto-fill)) (dolist (buffer (buffer-list)) (with-current-buffer buffer (if (or (derived-mode-p 'text-mode) text-mode-variant) @@ -214,15 +211,14 @@ The argument NLINES says how many lines to center." (while (not (eq nlines 0)) (save-excursion (let ((lm (current-left-margin)) - line-length) + space) (beginning-of-line) (delete-horizontal-space) (end-of-line) (delete-horizontal-space) - (setq line-length (current-column)) - (if (> (- fill-column lm line-length) 0) - (indent-line-to - (+ lm (/ (- fill-column lm line-length) 2)))))) + (setq space (- fill-column lm (current-column))) + (if (> space 0) + (indent-line-to (+ lm (/ space 2)))))) (cond ((null nlines) (setq nlines 0)) ((> nlines 0) commit 07d7852b00dc0c91f2450856ac27c17eea7a3e1a Author: Alan Third Date: Sun Mar 31 18:14:31 2019 +0100 Use the correct filename for dump file in NS * nextstep/Makefile.in (all): (${ns_appbindir}/Emacs.pdmp): (links): Use mixed case 'Emacs.pdmp' to match the executable name. diff --git a/nextstep/Makefile.in b/nextstep/Makefile.in index 4eda9f4e1a..08e2e510d3 100644 --- a/nextstep/Makefile.in +++ b/nextstep/Makefile.in @@ -44,7 +44,7 @@ ns_check_file = @ns_appdir@/@ns_check_file@ .PHONY: all -all: ${ns_appdir} ${ns_appbindir}/Emacs ${ns_appbindir}/emacs.pdmp +all: ${ns_appdir} ${ns_appbindir}/Emacs ${ns_appbindir}/Emacs.pdmp ${ns_check_file} ${ns_appdir}: ${srcdir}/${ns_appsrc} ${ns_appsrc} rm -rf ${ns_appdir} @@ -63,7 +63,7 @@ ${ns_appbindir}/Emacs: ${ns_appdir} ${ns_check_file} ../src/emacs${EXEEXT} ${MKDIR_P} ${ns_appbindir} cp -f ../src/emacs${EXEEXT} $@ -${ns_appbindir}/emacs.pdmp: ${ns_appdir} ${ns_check_file} ../src/emacs${EXEEXT}.pdmp +${ns_appbindir}/Emacs.pdmp: ${ns_appdir} ${ns_check_file} ../src/emacs${EXEEXT}.pdmp ${MKDIR_P} ${ns_appbindir} cp -f ../src/emacs${EXEEXT}.pdmp $@ @@ -85,7 +85,7 @@ links: ../src/emacs${EXEEXT} ln -s $(top_srcdir_abs)/info ${ns_appdir}/Contents/Resources ${MKDIR_P} ${ns_appbindir} ln -s $(abs_top_builddir)/src/emacs${EXEEXT} ${ns_appbindir}/Emacs - ln -s $(abs_top_builddir)/src/emacs${EXEEXT}.pdmp ${ns_appbindir}/ + ln -s $(abs_top_builddir)/src/emacs${EXEEXT}.pdmp ${ns_appbindir}/Emacs.pdmp ln -s $(abs_top_builddir)/lib-src ${ns_appbindir}/bin ln -s $(abs_top_builddir)/lib-src ${ns_appbindir}/libexec ${MKDIR_P} ${ns_appdir}/Contents/Resources/etc commit 0cd250e9583deb1e1f4d8dae2ec44c4f7c13efa6 Author: Basil L. Contovounesios Date: Wed Mar 27 15:13:25 2019 +0000 Fix recently extended delete-indentation behavior * doc/lispref/text.texi (User-Level Deletion): Document new optional arguments of delete-indentation. * lisp/simple.el (delete-indentation): Do not barf if called interactively when region is inactive. (bug#35021) Do not skip blank lines. (bug#35036) Consistently deactivate mark even when no text was changed. Handle active region spanning a single line. * test/lisp/simple-tests.el (simple-test--buffer-substrings): New convenience function. (simple-test--dummy-buffer, simple-test--transpositions): Use it. (simple-delete-indentation-no-region) (simple-delete-indentation-inactive-region): Update commentary. Call delete-indentation interactively when testing for behavior with inactive region and region is not explicitly defined. (simple-delete-indentation-blank-line) (simple-delete-indentation-boundaries) (simple-delete-indentation-region) (simple-delete-indentation-prefix): New tests. diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 21c5a73f88..b430adf597 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -723,12 +723,18 @@ You thought @end example @end deffn -@deffn Command delete-indentation &optional join-following-p +@deffn Command delete-indentation &optional join-following-p beg end This function joins the line point is on to the previous line, deleting any whitespace at the join and in some cases replacing it with one space. If @var{join-following-p} is non-@code{nil}, @code{delete-indentation} joins this line to the following line -instead. The function returns @code{nil}. +instead. Otherwise, if @var{beg} and @var{end} are non-@code{nil}, +this function joins all lines in the region they define. + +In an interactive call, @var{join-following-p} is the prefix argument, +and @var{beg} and @var{end} are, respectively, the start and end of +the region if it is active, else @code{nil}. The function returns +@code{nil}. If there is a fill prefix, and the second of the lines being joined starts with the prefix, then @code{delete-indentation} deletes the diff --git a/lisp/simple.el b/lisp/simple.el index f76f31ad14..306df96766 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -598,30 +598,38 @@ When called from Lisp code, ARG may be a prefix string to copy." If there is a fill prefix, delete it from the beginning of this line. With prefix ARG, join the current line to the following line. -If the region is active, join all the lines in the region. (The -region is ignored if prefix argument is given.)" - (interactive "*P\nr") - (if arg (forward-line 1) - (if (use-region-p) - (goto-char end))) - (beginning-of-line) - (while (eq (preceding-char) ?\n) - (progn - (delete-region (point) (1- (point))) - ;; If the second line started with the fill prefix, +When BEG and END are non-nil, join all lines in the region they +define. Interactively, BEG and END are, respectively, the start +and end of the region if it is active, else nil. (The region is +ignored if prefix ARG is given.)" + (interactive + (progn (barf-if-buffer-read-only) + (cons current-prefix-arg + (and (use-region-p) + (list (region-beginning) (region-end)))))) + ;; Consistently deactivate mark even when no text is changed. + (setq deactivate-mark t) + (if (and beg (not arg)) + ;; Region is active. Go to END, but only if region spans + ;; multiple lines. + (and (goto-char beg) + (> end (line-end-position)) + (goto-char end)) + ;; Region is inactive. Set a loop sentinel + ;; (subtracting 1 in order to compare less than BOB). + (setq beg (1- (line-beginning-position (and arg 2)))) + (when arg (forward-line))) + (let ((prefix (and (> (length fill-prefix) 0) + (regexp-quote fill-prefix)))) + (while (and (> (line-beginning-position) beg) + (forward-line 0) + (= (preceding-char) ?\n)) + (delete-char -1) + ;; If the appended line started with the fill prefix, ;; delete the prefix. - (if (and fill-prefix - (<= (+ (point) (length fill-prefix)) (point-max)) - (string= fill-prefix - (buffer-substring (point) - (+ (point) (length fill-prefix))))) - (delete-region (point) (+ (point) (length fill-prefix)))) - (fixup-whitespace) - (if (and (use-region-p) - beg - (not arg) - (< beg (point-at-bol))) - (beginning-of-line))))) + (if (and prefix (looking-at prefix)) + (replace-match "" t t)) + (fixup-whitespace)))) (defalias 'join-line #'delete-indentation) ; easier to find diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el index d9f059c8fc..cc2feebbef 100644 --- a/test/lisp/simple-tests.el +++ b/test/lisp/simple-tests.el @@ -22,6 +22,11 @@ (require 'ert) (eval-when-compile (require 'cl-lib)) +(defun simple-test--buffer-substrings () + "Return cons of buffer substrings before and after point." + (cons (buffer-substring (point-min) (point)) + (buffer-substring (point) (point-max)))) + (defmacro simple-test--dummy-buffer (&rest body) (declare (indent 0) (debug t)) @@ -31,10 +36,7 @@ (insert "(a b") (save-excursion (insert " c d)")) ,@body - (with-no-warnings - (cons (buffer-substring (point-min) (point)) - (buffer-substring (point) (point-max)))))) - + (with-no-warnings (simple-test--buffer-substrings)))) ;;; `transpose-sexps' @@ -46,8 +48,7 @@ (insert "(s1) (s2) (s3) (s4) (s5)") (backward-sexp 1) ,@body - (cons (buffer-substring (point-min) (point)) - (buffer-substring (point) (point-max))))) + (simple-test--buffer-substrings))) ;;; Transposition with negative args (bug#20698, bug#21885) (ert-deftest simple-transpose-subr () @@ -215,37 +216,144 @@ ;;; `delete-indentation' + (ert-deftest simple-delete-indentation-no-region () - "delete-indentation works when no mark is set." - ;; interactive \r returns nil for BEG END args - (unwind-protect - (with-temp-buffer - (insert (concat "zero line \n" - "first line \n" - "second line")) - (delete-indentation) - (should (string-equal - (buffer-string) - (concat "zero line \n" - "first line second line"))) - ))) + "Test `delete-indentation' when no mark is set; see bug#35021." + (with-temp-buffer + (insert " first \n second \n third \n fourth ") + (should-not (mark t)) + ;; Without prefix argument. + (should-not (call-interactively #'delete-indentation)) + (should (equal (simple-test--buffer-substrings) + '(" first \n second \n third" . " fourth "))) + (should-not (call-interactively #'delete-indentation)) + (should (equal (simple-test--buffer-substrings) + '(" first \n second" . " third fourth "))) + ;; With prefix argument. + (goto-char (point-min)) + (let ((current-prefix-arg '(4))) + (should-not (call-interactively #'delete-indentation))) + (should (equal (simple-test--buffer-substrings) + '(" first" . " second third fourth "))))) (ert-deftest simple-delete-indentation-inactive-region () - "delete-indentation ignores inactive region." - ;; interactive \r returns non-nil for BEG END args - (unwind-protect - (with-temp-buffer - (insert (concat "zero line \n" - "first line \n" - "second line")) - (push-mark (point-min) t t) - (deactivate-mark) - (delete-indentation) - (should (string-equal - (buffer-string) - (concat "zero line \n" - "first line second line"))) - ))) + "Test `delete-indentation' with an inactive region." + (with-temp-buffer + (insert " first \n second \n third ") + (set-marker (mark-marker) (point-min)) + (should (mark t)) + (should-not (call-interactively #'delete-indentation)) + (should (equal (simple-test--buffer-substrings) + '(" first \n second" . " third "))))) + +(ert-deftest simple-delete-indentation-blank-line () + "Test `delete-indentation' does not skip blank lines. +See bug#35036." + (with-temp-buffer + (insert "\n\n third \n \n \n sixth \n\n") + ;; Without prefix argument. + (should-not (delete-indentation)) + (should (equal (simple-test--buffer-substrings) + '("\n\n third \n \n \n sixth \n" . ""))) + (should-not (delete-indentation)) + (should (equal (simple-test--buffer-substrings) + '("\n\n third \n \n \n sixth" . ""))) + (should-not (delete-indentation)) + (should (equal (simple-test--buffer-substrings) + '("\n\n third \n \n" . "sixth"))) + ;; With prefix argument. + (goto-char (point-min)) + (should-not (delete-indentation t)) + (should (equal (simple-test--buffer-substrings) + '("" . "\n third \n \nsixth"))) + (should-not (delete-indentation t)) + (should (equal (simple-test--buffer-substrings) + '("" . "third \n \nsixth"))) + (should-not (delete-indentation t)) + (should (equal (simple-test--buffer-substrings) + '("third" . "\nsixth"))) + (should-not (delete-indentation t)) + (should (equal (simple-test--buffer-substrings) + '("third" . " sixth"))))) + +(ert-deftest simple-delete-indentation-boundaries () + "Test `delete-indentation' motion at buffer boundaries." + (with-temp-buffer + (insert " first \n second \n third ") + ;; Stay at EOB. + (should-not (delete-indentation t)) + (should (equal (simple-test--buffer-substrings) + '(" first \n second \n third " . ""))) + ;; Stay at BOB. + (forward-line -1) + (save-restriction + (narrow-to-region (point) (line-end-position)) + (should-not (delete-indentation)) + (should (equal (simple-test--buffer-substrings) + '("" . " second "))) + ;; Go to EOB. + (should-not (delete-indentation t)) + (should (equal (simple-test--buffer-substrings) + '(" second " . "")))) + ;; Go to BOB. + (end-of-line 0) + (should-not (delete-indentation)) + (should (equal (simple-test--buffer-substrings) + '("" . " first \n second \n third "))))) + +(ert-deftest simple-delete-indentation-region () + "Test `delete-indentation' with an active region." + (with-temp-buffer + ;; Empty region. + (insert " first ") + (should-not (delete-indentation nil (point) (point))) + (should (equal (simple-test--buffer-substrings) + '(" first " . ""))) + ;; Single line. + (should-not (delete-indentation + nil (line-beginning-position) (1- (point)))) + (should (equal (simple-test--buffer-substrings) + '("" . " first "))) + (should-not (delete-indentation nil (1+ (point)) (line-end-position))) + (should (equal (simple-test--buffer-substrings) + '(" " . "first "))) + (should-not (delete-indentation + nil (line-beginning-position) (line-end-position))) + (should (equal (simple-test--buffer-substrings) + '("" . " first "))) + ;; Multiple lines. + (goto-char (point-max)) + (insert "\n second \n third \n fourth ") + (goto-char (point-min)) + (should-not (delete-indentation + nil (line-end-position) (line-beginning-position 2))) + (should (equal (simple-test--buffer-substrings) + '(" first" . " second \n third \n fourth "))) + (should-not (delete-indentation + nil (point) (1+ (line-beginning-position 2)))) + (should (equal (simple-test--buffer-substrings) + '(" first second" . " third \n fourth "))) + ;; Prefix argument overrides region. + (should-not (delete-indentation t (point-min) (point))) + (should (equal (simple-test--buffer-substrings) + '(" first second third" . " fourth "))))) + +(ert-deftest simple-delete-indentation-prefix () + "Test `delete-indentation' with a fill prefix." + (with-temp-buffer + (insert "> first \n> second \n> third \n> fourth ") + (let ((fill-prefix "")) + (delete-indentation)) + (should (equal (simple-test--buffer-substrings) + '("> first \n> second \n> third" . " > fourth "))) + (let ((fill-prefix "<")) + (delete-indentation)) + (should (equal (simple-test--buffer-substrings) + '("> first \n> second" . " > third > fourth "))) + (let ((fill-prefix ">")) + (delete-indentation)) + (should (equal (simple-test--buffer-substrings) + '("> first" . " second > third > fourth "))))) ;;; `delete-trailing-whitespace' commit 99be0aba4defb8377cb148f7805ea07babc6182f Author: Eric Abrahamsen Date: Sun Mar 31 08:36:56 2019 -0700 Check gnus-newsgroup-dependencies is hash table in gnus-id-to-thread * lisp/gnus/gnus-sum.el (gnus-id-to-thread): If dependencies haven't been initialized yet, don't blow up. Mimicks previous (non hasht table) behavior. diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index f09c0fbb58..f5853a2430 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -4750,7 +4750,8 @@ If LINE, insert the rebuilt thread starting on line LINE." (defun gnus-id-to-thread (id) "Return the (sub-)thread where ID appears." - (gethash id gnus-newsgroup-dependencies)) + (when (hash-table-p gnus-newsgroup-dependencies) + (gethash id gnus-newsgroup-dependencies))) (defun gnus-id-to-article (id) "Return the article number of ID." commit 6d7e18e8015024ef06570e80086f58e834d6d4b6 Author: Mattias EngdegÄrd Date: Sun Mar 31 15:53:52 2019 +0200 Fix typo in regexp-opt example code * doc/lispref/searching.texi (Regexp Functions): Fix typo in example code (Bug#34596). diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi index 0f312915f9..e3f31fdf83 100644 --- a/doc/lispref/searching.texi +++ b/doc/lispref/searching.texi @@ -1007,9 +1007,9 @@ version: ((eq paren 'symbols) '("\\_<\\(" . "\\)\\_>")) ((null paren) '("\\(?:" . "\\)")) (t '("\\(" . "\\)"))))) - (concat (car paren) + (concat (car parens) (mapconcat 'regexp-quote strings "\\|") - (cdr paren)))) + (cdr parens)))) @end example @end defun