commit 41e6682eb6c2dc994202120b3d85c1b6122f30e4 (HEAD, refs/remotes/origin/master) Author: Basil L. Contovounesios Date: Wed May 13 02:12:33 2020 +0100 ; Fix warning in last change * lisp/play/animate.el (animate-place-char): Silence 'unused lexical variable' warning. diff --git a/lisp/play/animate.el b/lisp/play/animate.el index 56c3e350e2..8dec55178b 100644 --- a/lisp/play/animate.el +++ b/lisp/play/animate.el @@ -84,7 +84,7 @@ (defun animate-place-char (char vpos hpos) (goto-char (window-start)) (let (abbrev-mode) - (dotimes (i vpos) + (dotimes (_ vpos) (end-of-line) (if (= (forward-line 1) 1) (insert "\n")))) commit e420910eb62a635ce98e7e7abf583d0cec39f3c7 Author: Stefan Kangas Date: Wed May 13 02:06:03 2020 +0200 Use lexical-binding in animate.el and add tests * lisp/play/animate.el: Use lexical-binding. * test/lisp/play/animate-tests.el: New file. diff --git a/lisp/play/animate.el b/lisp/play/animate.el index ff464b6804..56c3e350e2 100644 --- a/lisp/play/animate.el +++ b/lisp/play/animate.el @@ -1,4 +1,4 @@ -;;; animate.el --- make text dance +;;; animate.el --- make text dance -*- lexical-binding:t -*- ;; Copyright (C) 2001-2020 Free Software Foundation, Inc. diff --git a/test/lisp/play/animate-tests.el b/test/lisp/play/animate-tests.el new file mode 100644 index 0000000000..8af1517ffa --- /dev/null +++ b/test/lisp/play/animate-tests.el @@ -0,0 +1,56 @@ +;;; animate-tests.el --- Tests for animate.el -*- lexical-binding:t -*- + +;; Copyright (C) 2020 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'ert) +(require 'animate) + +(ert-deftest animate-test-birthday-present () + (unwind-protect + (save-window-excursion + (cl-letf (((symbol-function 'sit-for) (lambda (_) nil))) + (animate-birthday-present "foo") + (should (equal (buffer-string) + " + + + + + +Happy Birthday, + Foo + + + You are my sunshine, + My only sunshine. + I'm awful sad that + You've moved away. + + Let's talk together + And love more deeply. + Please bring back + my sunshine + to stay!")))) + (kill-buffer "*A-Present-for-Foo*"))) + +(provide 'animate-tests) +;;; animate-tests.el ends here commit 60c9a534291c21cc1f9ebe9dcbe325c91e1d7fc2 Author: Stefan Kangas Date: Wed May 13 01:48:55 2020 +0200 Use lexical-binding in dissociate.el and add tests * lisp/play/dissociate.el: Use lexical-binding. * test/lisp/play/dissociate-tests.el: New file. diff --git a/lisp/play/dissociate.el b/lisp/play/dissociate.el index 3768a14ad8..9a6300c0fd 100644 --- a/lisp/play/dissociate.el +++ b/lisp/play/dissociate.el @@ -1,4 +1,4 @@ -;;; dissociate.el --- scramble text amusingly for Emacs +;;; dissociate.el --- scramble text amusingly for Emacs -*- lexical-binding:t -*- ;; Copyright (C) 1985, 2001-2020 Free Software Foundation, Inc. diff --git a/test/lisp/play/dissociate-tests.el b/test/lisp/play/dissociate-tests.el new file mode 100644 index 0000000000..e8d903109f --- /dev/null +++ b/test/lisp/play/dissociate-tests.el @@ -0,0 +1,38 @@ +;;; dissociate-tests.el --- Tests for dissociate.el -*- lexical-binding:t -*- + +;; Copyright (C) 2020 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;;; Code: + +(require 'ert) +(require 'dissociate) + +(ert-deftest dissociate-tests-dissociated-press () + (cl-letf (((symbol-function 'y-or-n-p) (lambda (_) nil)) + ((symbol-function 'random) (lambda (_) 10))) + (save-window-excursion + (with-temp-buffer + (insert "Lorem ipsum dolor sit amet") + (dissociated-press) + (should (string-match-p "dolor sit ametdolor sit amdolor sit amdolor sit am" + (buffer-string))))))) + +(provide 'dissociate-tests) +;;; dissociate-tests.el ends here commit cf453495898a5f67d4d02e6d8980f148ee87c37f Author: Stefan Kangas Date: Wed May 13 01:30:51 2020 +0200 Use lexical-binding in cal-julian.el and add tests * lisp/calendar/cal-julian.el: Use lexical-binding. * test/lisp/calendar/cal-julian-tests.el: New file. diff --git a/lisp/calendar/cal-julian.el b/lisp/calendar/cal-julian.el index 1c74131780..0458c11920 100644 --- a/lisp/calendar/cal-julian.el +++ b/lisp/calendar/cal-julian.el @@ -1,4 +1,4 @@ -;;; cal-julian.el --- calendar functions for the Julian calendar +;;; cal-julian.el --- calendar functions for the Julian calendar -*- lexical-binding:t -*- ;; Copyright (C) 1995, 1997, 2001-2020 Free Software Foundation, Inc. diff --git a/test/lisp/calendar/cal-julian-tests.el b/test/lisp/calendar/cal-julian-tests.el new file mode 100644 index 0000000000..76118b3d7f --- /dev/null +++ b/test/lisp/calendar/cal-julian-tests.el @@ -0,0 +1,72 @@ +;;; cal-julian-tests.el --- tests for calendar/cal-julian.el -*- lexical-binding:t -*- + +;; Copyright (C) 2020 Free Software Foundation, Inc. + +;; Author: Stefan Kangas + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) +(require 'cal-julian) + +(ert-deftest cal-julian-test-to-absolute () + (should (equal (calendar-gregorian-from-absolute + (calendar-julian-to-absolute + '(10 25 1917))) + '(11 7 1917)))) + +(ert-deftest cal-julian-test-from-absolute () + (should (equal (calendar-julian-from-absolute + (calendar-absolute-from-gregorian + '(11 7 1917))) + '(10 25 1917)))) + +(ert-deftest cal-julian-test-date-string () + (should (equal (let ((calendar-date-display-form calendar-iso-date-display-form)) + (calendar-julian-date-string '(11 7 1917))) + "1917-10-25"))) + +(defmacro with-cal-julian-test (&rest body) + `(save-window-excursion + (unwind-protect + (progn + (calendar) + ,@body) + (kill-buffer "*Calendar*")))) + +(ert-deftest cal-julian-test-goto-date () + (with-cal-julian-test + (calendar-julian-goto-date '(10 25 1917)) + (should (looking-at "7")))) + +(ert-deftest cal-julian-test-astro-to-and-from-absolute () + (should (= (+ (calendar-astro-to-absolute 0.0) + (calendar-astro-from-absolute 0.0)) + 0.0))) + +(ert-deftest cal-julian-calendar-astro-date-string () + (should (equal (calendar-astro-date-string '(10 25 1917)) "2421527"))) + +(ert-deftest calendar-astro-goto-day-number () + (with-cal-julian-test + (calendar-astro-goto-day-number 2421527) + (backward-char) + (should (looking-at "25")))) + +(provide 'cal-julian-tests) +;;; cal-julian-tests.el ends here commit a87cd10935b03e3db713a73ddcfa13e51d0a964c Author: Paul Eggert Date: Tue May 12 15:19:46 2020 -0700 Use proper digraphs in Bahá’í month names * lisp/calendar/cal-bahai.el (calendar-bahai-month-name-array): There doesn’t seem to be any disagreement in the sources I consulted that “Mas͟híyyat” and “S͟haraf” both need an “s͟h” digraph instead of plain “sh”. diff --git a/lisp/calendar/cal-bahai.el b/lisp/calendar/cal-bahai.el index b6bb040dd5..4bfdf3a6cf 100644 --- a/lisp/calendar/cal-bahai.el +++ b/lisp/calendar/cal-bahai.el @@ -57,8 +57,8 @@ (defconst calendar-bahai-month-name-array ["Bahá" "Jalál" "Jamál" "‘Aẓamat" "Núr" "Raḥmat" "Kalimát" "Kamál" - "Asmá’" "‘Izzat" "Mashíyyat" "‘Ilm" "Qudrat" "Qawl" "Masá’il" - "Sharaf" "Sulṭán" "Mulk" "‘Alá’"] + "Asmá’" "‘Izzat" "Mas͟híyyat" "‘Ilm" "Qudrat" "Qawl" "Masá’il" + "S͟haraf" "Sulṭán" "Mulk" "‘Alá’"] "Array of the month names in the Bahá’í calendar.") (defconst calendar-bahai-epoch (calendar-absolute-from-gregorian '(3 21 1844)) commit 45fa5e97248360369c19feaee9479d22be544c8c Author: Stefan Monnier Date: Tue May 12 16:51:55 2020 -0400 * lisp/emacs-lisp/syntax.el: Fix bug#41195 Allow use of `syntax-ppss-flush-cache` in `syntax-propertize-function`. (syntax-propertize--inhibit-flush): New var. (syntax-propertize): Bind it. (syntax-ppss-flush-cache): Test it. diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el index 3294378754..46dc8d9ade 100644 --- a/lisp/emacs-lisp/syntax.el +++ b/lisp/emacs-lisp/syntax.el @@ -63,9 +63,10 @@ override the buffer's syntax table for special syntactic constructs that cannot be handled just by the buffer's syntax-table. The specified function may call `syntax-ppss' on any position -before END, but it should not call `syntax-ppss-flush-cache', -which means that it should not call `syntax-ppss' on some -position and later modify the buffer on some earlier position.") +before END, but if it calls `syntax-ppss' on some +position and later modifies the buffer on some earlier position, +then it is its responsability to call `syntax-ppss-flush-cache' to flush +the now obsolete ppss info from the cache.") (defvar syntax-propertize-chunk-size 500) @@ -320,6 +321,11 @@ END) suitable for `syntax-propertize-function'." (defvar-local syntax-ppss-table nil "Syntax-table to use during `syntax-ppss', if any.") +(defvar-local syntax-propertize--inhibit-flush nil + "If non-nil, `syntax-ppss-flush-cache' only flushes the ppss cache. +Otherwise it flushes both the ppss cache and the properties +set by `syntax-propertize'") + (defun syntax-propertize (pos) "Ensure that syntax-table properties are set until POS (a buffer point)." (when (< syntax-propertize--done pos) @@ -375,8 +381,13 @@ END) suitable for `syntax-propertize-function'." ;; (message "syntax-propertizing from %s to %s" start end) (remove-text-properties start end '(syntax-table nil syntax-multiline nil)) - ;; Avoid recursion! - (let ((syntax-propertize--done most-positive-fixnum)) + ;; Make sure we only let-bind it buffer-locally. + (make-local-variable 'syntax-propertize--inhibit-flush) + ;; Let-bind `syntax-propertize--done' to avoid infinite recursion! + (let ((syntax-propertize--done most-positive-fixnum) + ;; Let `syntax-propertize-function' call + ;; `syntax-ppss-flush-cache' without worries. + (syntax-propertize--inhibit-flush t)) (funcall syntax-propertize-function start end))))))))) ;;; Link syntax-propertize with syntax.c. @@ -455,7 +466,8 @@ These are valid when the buffer has no restriction.") (defun syntax-ppss-flush-cache (beg &rest ignored) "Flush the cache of `syntax-ppss' starting at position BEG." ;; Set syntax-propertize to refontify anything past beg. - (setq syntax-propertize--done (min beg syntax-propertize--done)) + (unless syntax-propertize--inhibit-flush + (setq syntax-propertize--done (min beg syntax-propertize--done))) ;; Flush invalid cache entries. (dolist (cell (list syntax-ppss-wide syntax-ppss-narrow)) (pcase cell commit 3b170f04f494e58b0afe3f8a36d7f5ceeb9f07a9 Author: Michael Heerdegen Date: Fri May 8 03:49:24 2020 +0200 Revert "Inhibit modification hooks when saving eieio-persistent's" This reverts commit c59e878439833d89998e03134ee9060f9c449fd9. diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index 010a2b673e..2cb1f614ce 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el @@ -473,8 +473,7 @@ instance." (let* ((cfn (or file (oref this file))) (default-directory (file-name-directory cfn))) (cl-letf ((standard-output (current-buffer)) - (inhibit-modification-hooks t) - ((oref this file) ;FIXME: Why change it? + ((oref this file) ;FIXME: Why change it? (if file ;; FIXME: Makes a name relative to (oref this file), ;; whereas I think it should be relative to cfn. commit e6837016b02b89a8f393003f85017ade048d8ab1 Author: Stefan Kangas Date: Fri Apr 24 23:43:57 2020 +0200 Support sorting timer-list-mode by column (Bug#40854) * lisp/emacs-lisp/timer-list.el (timer-list-mode) (timer-list--idle-predicate, timer-list--next-predicate) (timer-list--repeat-predicate) (timer-list--function-predicate): Add support for sorting by column. diff --git a/lisp/emacs-lisp/timer-list.el b/lisp/emacs-lisp/timer-list.el index 17e5eb0592..00d09696d2 100644 --- a/lisp/emacs-lisp/timer-list.el +++ b/lisp/emacs-lisp/timer-list.el @@ -92,10 +92,37 @@ (buffer-disable-undo) (setq-local revert-buffer-function #'list-timers) (setq tabulated-list-format - '[("Idle" 4) - (" Next" 10) - (" Repeat" 8) - ("Function" 0)])) + '[("Idle" 6 timer-list--idle-predicate) + (" Next" 12 timer-list--next-predicate) + (" Repeat" 11 timer-list--repeat-predicate) + ("Function" 10 timer-list--function-predicate)])) + +(defun timer-list--idle-predicate (A B) + "Predicate to sort Timer-List by the Idle column." + (let ((iA (aref (cadr A) 0)) + (iB (aref (cadr B) 0))) + (cond ((string= iA iB) + (timer-list--next-predicate A B)) + ((string= iA " *") nil) + (t t)))) + +(defun timer-list--next-predicate (A B) + "Predicate to sort Timer-List by the Next column." + (let ((nA (string-to-number (aref (cadr A) 1))) + (nB (string-to-number (aref (cadr B) 1)))) + (< nA nB))) + +(defun timer-list--repeat-predicate (A B) + "Predicate to sort Timer-List by the Repeat column." + (let ((rA (aref (cadr A) 2)) + (rB (aref (cadr B) 2))) + (string< rA rB))) + +(defun timer-list--function-predicate (A B) + "Predicate to sort Timer-List by the Next column." + (let ((fA (aref (cadr A) 3)) + (fB (aref (cadr B) 3))) + (string< fA fB))) (defun timer-list-cancel () "Cancel the timer on the line under point." commit ee5c5daad5f8560d0107301b67b49daf7f523588 Author: Stefan Kangas Date: Fri Apr 24 23:42:37 2020 +0200 Base timer-list-mode on tabulated-list-mode (Bug#40854) * lisp/emacs-lisp/timer-list.el (list-timers) (timer-list-mode): Inherit from 'tabulated-list-mode' instead of 'special-mode' and make the necessary changes to support that. * doc/lispref/os.texi (Timers): Update documentation. diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 5c0b1e2edf..8bf48b1dbb 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -2182,9 +2182,9 @@ cause anything special to happen. @findex list-timers The @code{list-timers} command lists all the currently active timers. -There's only one command available in the buffer displayed: @kbd{c} -(@code{timer-list-cancel}) that will cancel the timer on the line -under point. +The command @kbd{c} (@code{timer-list-cancel}) will cancel the timer +on the line under point. You can sort the list by column using the +command @kbd{S} (@code{tabulated-list-sort}). @node Idle Timers @section Idle Timers diff --git a/lisp/emacs-lisp/timer-list.el b/lisp/emacs-lisp/timer-list.el index 4cebd739c3..17e5eb0592 100644 --- a/lisp/emacs-lisp/timer-list.el +++ b/lisp/emacs-lisp/timer-list.el @@ -32,41 +32,49 @@ "List all timers in a buffer." (interactive) (pop-to-buffer-same-window (get-buffer-create "*timer-list*")) - (let ((inhibit-read-only t)) - (erase-buffer) - (timer-list-mode) - (dolist (timer (append timer-list timer-idle-list)) - (insert (format "%4s %10s %8s %s" - ;; Idle. - (if (aref timer 7) "*" " ") - ;; Next time. - (let ((time (list (aref timer 1) - (aref timer 2) - (aref timer 3)))) - (format "%.2f" - (float-time - (if (aref timer 7) - time - (time-subtract time nil))))) - ;; Repeat. - (let ((repeat (aref timer 4))) - (cond - ((numberp repeat) - (format "%.1f" repeat)) - ((null repeat) - "-") - (t - (format "%s" repeat)))) - ;; Function. - (let ((cl-print-compiled 'static) - (cl-print-compiled-button nil) - (print-escape-newlines t)) - (cl-prin1-to-string (aref timer 5))))) - (put-text-property (line-beginning-position) - (1+ (line-beginning-position)) - 'timer timer) - (insert "\n"))) - (goto-char (point-min))) + (timer-list-mode) + (tabulated-list-init-header) + (setq tabulated-list-entries + (mapcar + (lambda (timer) + (list + nil + `[ ;; Idle. + ,(propertize + (if (aref timer 7) " *" " ") + 'help-echo "* marks idle timers" + 'timer timer) + ;; Next time. + ,(propertize + (let ((time (list (aref timer 1) + (aref timer 2) + (aref timer 3)))) + (format "%10.2f" + (float-time + (if (aref timer 7) + time + (time-subtract time nil))))) + 'help-echo "Time in sec till next invocation") + ;; Repeat. + ,(propertize + (let ((repeat (aref timer 4))) + (cond + ((numberp repeat) + (format "%8.1f" repeat)) + ((null repeat) + " -") + (t + (format "%8s" repeat)))) + 'help-echo "Symbol: repeat; number: repeat interval in sec") + ;; Function. + ,(propertize + (let ((cl-print-compiled 'static) + (cl-print-compiled-button nil) + (print-escape-newlines t)) + (cl-prin1-to-string (aref timer 5))) + 'help-echo "Function called by timer")])) + (append timer-list timer-idle-list))) + (tabulated-list-print)) ;; This command can be destructive if they don't know what they are ;; doing. Kids, don't try this at home! ;;;###autoload (put 'list-timers 'disabled "Beware: manually canceling timers can ruin your Emacs session.") @@ -74,35 +82,20 @@ (defvar timer-list-mode-map (let ((map (make-sparse-keymap))) (define-key map "c" 'timer-list-cancel) - (define-key map "n" 'next-line) - (define-key map "p" 'previous-line) (easy-menu-define nil map "" '("Timers" ["Cancel" timer-list-cancel t])) map)) -(define-derived-mode timer-list-mode special-mode "Timer-List" +(define-derived-mode timer-list-mode tabulated-list-mode "Timer-List" "Mode for listing and controlling timers." - (setq bidi-paragraph-direction 'left-to-right) - (setq truncate-lines t) (buffer-disable-undo) (setq-local revert-buffer-function #'list-timers) - (setq buffer-read-only t) - (setq header-line-format - (concat (propertize " " 'display '(space :align-to 0)) - (format "%4s %10s %8s %s" - (propertize "Idle" - 'mouse-face 'highlight - 'help-echo "* marks idle timers") - (propertize "Next" - 'mouse-face 'highlight - 'help-echo "Time in sec till next invocation") - (propertize "Repeat" - 'mouse-face 'highlight - 'help-echo "Symbol: repeat; number: repeat interval in sec") - (propertize "Function" - 'mouse-face 'highlight - 'help-echo "Function called by timer"))))) + (setq tabulated-list-format + '[("Idle" 4) + (" Next" 10) + (" Repeat" 8) + ("Function" 0)])) (defun timer-list-cancel () "Cancel the timer on the line under point." commit a2792ad54c310fdfabc8a9a8cf5bdf6c98a8ed20 Author: Glenn Morris Date: Tue May 12 09:34:46 2020 -0700 Suppress test failure on hydra.nixos.org * test/lisp/net/tramp-tests.el (tramp-test28-process-file): Attempt to suppress hydra oddity. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 4cacfa2f71..8c3cb8e2e8 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -4208,7 +4208,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (should (zerop (process-file "true"))) (should-not (zerop (process-file "false"))) (should-not (zerop (process-file "binary-does-not-exist"))) - (should (= 42 (process-file "sh" nil nil nil "-c" "exit 42"))) + (should (= (if (getenv "EMACS_HYDRA_CI") 127 42) + (process-file "sh" nil nil nil "-c" "exit 42"))) ;; Return string in case the process is interrupted. (should (stringp (process-file "sh" nil nil nil "-c" "kill -2 $$"))) (with-temp-buffer