commit c44068ac6c6f31a3b64ad19841d7f0385f624dae (HEAD, refs/remotes/origin/master) Author: Po Lu Date: Thu Jul 28 10:59:19 2022 +0800 * src/xterm.c (x_set_offset): Respect x-no-window-manager. diff --git a/src/xterm.c b/src/xterm.c index 7b4a65e87f..e7222d35b3 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -24322,7 +24322,11 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_gravity) #endif /* 'x_sync_with_move' is too costly for dragging child frames. */ - if (!FRAME_PARENT_FRAME (f)) + if (!FRAME_PARENT_FRAME (f) + /* If no window manager exists, just calling XSync will be + sufficient to ensure that the window geometry has been + updated. */ + && NILP (Vx_no_window_manager)) { x_sync_with_move (f, f->left_pos, f->top_pos, FRAME_DISPLAY_INFO (f)->wm_type == X_WMTYPE_UNKNOWN); commit f720630195357440af179607aa74e8ed14a58e83 Author: Po Lu Date: Thu Jul 28 09:25:37 2022 +0800 Remove excessive synchronization from x_sync_with_move * src/xterm.c (x_sync_with_move): Remove redundant XSync. The X server always handles requests in order. diff --git a/src/xterm.c b/src/xterm.c index 2067e8bb74..7b4a65e87f 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -25055,11 +25055,9 @@ x_sync_with_move (struct frame *f, int left, int top, bool fuzzy) current_left = 0; current_top = 0; - /* In theory, this call to XSync only needs to happen once, but in - practice, it doesn't seem to work, hence the need for the surrounding - loop. */ - - XSync (FRAME_X_DISPLAY (f), False); + /* There is no need to call XSync (even when no window manager + is present) because x_real_positions already does that + implicitly. */ x_real_positions (f, ¤t_left, ¤t_top); if (fuzzy) commit 9ad5421a62ab2780f1116bc4bbf88b32d4472d64 Author: Stefan Kangas Date: Thu Jul 28 00:25:33 2022 +0200 Drop support for obsolete "Lisp Code Directory" from ffap Ref: https://flex.phys.tohoku.ac.jp/texi/faq/faq_146.html Note also that the host "archive.cis.ohio-state.edu" is unknown. * lisp/ffap.el (ffap-alist): Drop support for obsolete "Lisp Code Directory". (ffap-lcd): Make obsolete. diff --git a/lisp/ffap.el b/lisp/ffap.el index a81d913014..d490cd434a 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -778,7 +778,6 @@ This uses `ffap-file-exists-string', which may try adding suffixes from ("\\.\\(tex\\|sty\\|doc\\|cls\\)\\'" . ffap-tex) ("\\.bib\\'" . ffap-bib) ; search ffap-bib-path ("\\`\\." . ffap-home) ; .emacs, .bashrc, .profile - ("\\`~/" . ffap-lcd) ; |~/misc/ffap.el.Z| ;; This used to have a blank, but ffap-string-at-point doesn't ;; handle blanks. ;; https://lists.gnu.org/r/emacs-devel/2008-01/msg01058.html @@ -1026,7 +1025,7 @@ out of NAME." ;; Maybe a "Lisp Code Directory" reference: (defun ffap-lcd (name) - ;; FIXME: Is this still in use? + (declare (obsolete nil "29.1")) (and (or ;; lisp-dir-apropos output buffer: commit 0add6a29c789c3c3f03c7ae1e5420df57885f5c6 Author: Stefan Kangas Date: Thu Jul 28 00:17:53 2022 +0200 ; * lisp/ffap.el: Delete code commented out since 1997. diff --git a/lisp/ffap.el b/lisp/ffap.el index 93c5c1faa9..a81d913014 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -640,18 +640,6 @@ Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"." ;;; File Name Handling: -;; -;; The upcoming ffap-alist actions need various utilities to prepare -;; and search directories. Too many features here. - -;; (defun ffap-last (l) (while (cdr l) (setq l (cdr l))) l) -;; (defun ffap-splice (func inlist) -;; "Equivalent to (apply 'nconc (mapcar FUNC INLIST)), but less consing." -;; (let* ((head (cons 17 nil)) (last head)) -;; (while inlist -;; (setcdr last (funcall func (car inlist))) -;; (setq last (ffap-last last) inlist (cdr inlist))) -;; (cdr head))) (defun ffap-list-env (env &optional empty) "Return a list of strings parsed from environment variable ENV. commit fcaad9905360264140d451dac5085dd4552a1e8f Author: Stefan Kangas Date: Wed Jul 27 23:33:03 2022 +0200 Drop support for XEmacs package EFS EFS is a long defunct XEmacs-specific fork of Ange FTP that is superseded by TRAMP. * lisp/ffap.el (ffap-ftp-default-user) (ffap-replace-file-component, ffap-host-to-filename): * lisp/gnus/mml.el (mml-parse-file-name): * lisp/gnus/nnheader.el (nnheader-re-read-dir): * lisp/net/browse-url.el (browse-url-filename-alist): * lisp/speedbar.el (speedbar-check-vc): Drop support for XEmacs package EFS. diff --git a/lisp/ffap.el b/lisp/ffap.el index a6cb01a93b..93c5c1faa9 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -173,7 +173,7 @@ well-formed, such as \"user@host\" or \"\"." (defcustom ffap-ftp-default-user "anonymous" "User name in FTP file names generated by `ffap-host-to-filename'. Note this name may be omitted if it equals the default -\(either `efs-default-user' or `ange-ftp-default-user')." +(`ange-ftp-default-user')." :type 'string :group 'ffap) @@ -495,12 +495,9 @@ Returned values: (defun ffap-replace-file-component (fullname name) "In remote FULLNAME, replace path with NAME. May return nil." - ;; Use efs if loaded, but do not load it otherwise. - (if (fboundp 'efs-replace-path-component) - (funcall 'efs-replace-path-component fullname name) - (and (stringp fullname) - (stringp name) - (concat (file-remote-p fullname) name)))) + (and (stringp fullname) + (stringp name) + (concat (file-remote-p fullname) name))) ;; (ffap-replace-file-component "/who@foo.com:/whatever" "/new") (defun ffap-file-suffix (file) @@ -569,9 +566,8 @@ Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"." "" (let ((user ffap-ftp-default-user)) ;; Avoid including the user if it is same as default: - (if (or (equal user (ffap-symbol-value 'ange-ftp-default-user)) - (equal user (ffap-symbol-value 'efs-default-user))) - (setq user nil)) + (when (equal user (ffap-symbol-value 'ange-ftp-default-user)) + (setq user nil)) (concat "/" user (and user "@") host ":")))) (defun ffap-fixup-machine (mach) diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el index 093e582ea7..a36f29ba10 100644 --- a/lisp/gnus/mml.el +++ b/lisp/gnus/mml.el @@ -980,13 +980,10 @@ type detected." (symbol-name type) value)))))) (defvar ange-ftp-name-format) -(defvar efs-path-regexp) (defun mml-parse-file-name (path) - (if (if (boundp 'efs-path-regexp) - (string-match efs-path-regexp path) - (if (boundp 'ange-ftp-name-format) - (string-match (car ange-ftp-name-format) path))) + (if (and (boundp 'ange-ftp-name-format) + (string-match (car ange-ftp-name-format) path)) (list (match-string 1 path) (match-string 2 path) (substring path (1+ (match-end 2)))) path)) diff --git a/lisp/gnus/nnheader.el b/lisp/gnus/nnheader.el index c1c5f00ff7..ab57bd7eed 100644 --- a/lisp/gnus/nnheader.el +++ b/lisp/gnus/nnheader.el @@ -918,15 +918,11 @@ first. Otherwise, find the newest one, though it may take a time." (car (sort results #'file-newer-than-file-p))))) (defvar ange-ftp-path-format) -(defvar efs-path-regexp) (defun nnheader-re-read-dir (path) "Re-read directory PATH if PATH is on a remote system." - (if (and (fboundp 'efs-re-read-dir) (boundp 'efs-path-regexp)) - (when (string-match efs-path-regexp path) - (efs-re-read-dir path)) - (when (and (fboundp 'ange-ftp-re-read-dir) (boundp 'ange-ftp-path-format)) - (when (string-match (car ange-ftp-path-format) path) - (ange-ftp-re-read-dir path))))) + (when (and (fboundp 'ange-ftp-re-read-dir) (boundp 'ange-ftp-path-format)) + (when (string-match (car ange-ftp-path-format) path) + (ange-ftp-re-read-dir path)))) (defun nnheader-insert-file-contents (filename &optional visit beg end replace) "Like `insert-file-contents', q.v., but only reads in the file. diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 6713208d26..2d528c4862 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -403,7 +403,7 @@ commands reverses the effect of this variable." Any substring of a filename matching one of the REGEXPs is replaced by the corresponding STRING using `replace-match', not treating STRING literally. All pairs are applied in the order given. The default -value converts ange-ftp/EFS-style file names into ftp URLs and prepends +value converts ange-ftp-style file names into ftp URLs and prepends `file:' to any file name beginning with `/'. For example, adding to the default a specific translation of an ange-ftp diff --git a/lisp/speedbar.el b/lisp/speedbar.el index 9184d6c525..e74d6fd80a 100644 --- a/lisp/speedbar.el +++ b/lisp/speedbar.el @@ -2789,15 +2789,7 @@ to add more types of version control systems." (not (or (and (featurep 'ange-ftp) (string-match (car (symbol-value 'ange-ftp-name-format)) - (expand-file-name default-directory))) - ;; efs support: Bob Weiner - (and (featurep 'efs) - (string-match - (let ((reg (symbol-value 'efs-directory-regexp))) - (if (stringp reg) - reg - (car reg))) - (expand-file-name default-directory)))))) + (expand-file-name default-directory)))))) (setq speedbar-vc-to-do-point 0)) (if (numberp speedbar-vc-to-do-point) (progn commit faa007cebf4a50bc2f21f59fea1e0f0064948f84 Author: Stefan Kangas Date: Wed Jul 27 23:21:28 2022 +0200 Make ffap-file-suffix obsolete * lisp/ffap.el (ffap-file-suffix): Make obsolete in favor of file-name-extension. Update callers. diff --git a/lisp/ffap.el b/lisp/ffap.el index 9de0dd40d1..a6cb01a93b 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -505,6 +505,7 @@ Returned values: (defun ffap-file-suffix (file) "Return trailing `.foo' suffix of FILE, or nil if none." + (declare (obsolete file-name-extension "29.1")) (let ((pos (string-match "\\.[^./]*\\'" file))) (and pos (substring file pos nil)))) @@ -528,7 +529,7 @@ The optional NOMODIFY argument suppresses the extra search." ;; three reasons to suppress search: (nomodify nil) ((not (rassq 'jka-compr-handler file-name-handler-alist)) nil) - ((member (ffap-file-suffix file) ffap-compression-suffixes) nil) + ((member (file-name-extension file t) ffap-compression-suffixes) nil) (t ; ok, do the search (let ((list ffap-compression-suffixes) try ret) (while list commit 00897b63694069b0f2fb152fa74333c6f6418fc5 Author: Michael Albinus Date: Wed Jul 27 21:20:49 2022 +0200 Remove Tramp instrumentation diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index e1a45e4ad5..faf3182d4a 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -4865,13 +4865,8 @@ support symbolic links." (error-file (and error-buffer (with-parsed-tramp-file-name default-directory nil - (when (getenv "EMACS_EMBA_CI") - (tramp-test-message "Holla1")) - (prog1 - (tramp-make-tramp-file-name - v (tramp-make-tramp-temp-file v)) - (when (getenv "EMACS_EMBA_CI") - (tramp-test-message "Holla2")))))) + (tramp-make-tramp-file-name + v (tramp-make-tramp-temp-file v))))) (bname (buffer-name output-buffer)) (p (get-buffer-process output-buffer)) (dir default-directory) @@ -4954,25 +4949,17 @@ support symbolic links." (add-function :after (process-sentinel p) (lambda (_proc _string) - (when (getenv "EMACS_EMBA_CI") - (tramp-test-message "Holla3 %s" error-file)) (with-current-buffer error-buffer (insert-file-contents-literally error-file nil nil nil 'replace)) - (when (getenv "EMACS_EMBA_CI") - (tramp-test-message "Holla4 %s" error-file)) (delete-file error-file)))) - (display-buffer output-buffer '(nil (allow-no-window . t)))) - - ;; Insert error messages if they were separated. - (when (and error-file (not (process-live-p p))) - (when (getenv "EMACS_EMBA_CI") - (tramp-test-message "Holla5 %s" error-file)) - (with-current-buffer error-buffer - (insert-file-contents-literally error-file)) - (when (getenv "EMACS_EMBA_CI") - (tramp-test-message "Holla6 %s" error-file)) - (delete-file error-file))))) + (display-buffer output-buffer '(nil (allow-no-window . t))))) + + ;; Insert error messages if they were separated. + (when (and error-file (not (process-live-p p))) + (with-current-buffer error-buffer + (insert-file-contents-literally error-file)) + (delete-file error-file)))) ;; Synchronous case. (prog1 diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 9f88b5d5d3..5a8d9100e1 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -5349,7 +5349,7 @@ INPUT, if non-nil, is a string sent to the process." (ert-deftest tramp-test32-shell-command () "Check `shell-command'." - :tags (unless (getenv "EMACS_EMBA_CI") '(:expensive-test)) + :tags '(:expensive-test) (skip-unless (tramp--test-enabled)) (skip-unless (tramp--test-supports-processes-p)) ;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for @@ -5357,7 +5357,6 @@ INPUT, if non-nil, is a string sent to the process." (when (tramp--test-adb-p) (skip-unless (tramp--test-emacs27-p))) - (tramp--test-instrument-test-case (if (getenv "EMACS_EMBA_CI") 10 0) (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) (let ((tmp-name (tramp--test-make-temp-name nil quoted)) (default-directory ert-remote-temporary-file-directory) @@ -5400,21 +5399,13 @@ INPUT, if non-nil, is a string sent to the process." (let ((stderr (generate-new-buffer "*stderr*"))) (unwind-protect (with-temp-buffer - (when (getenv "EMACS_EMBA_CI") - (tramp--test-message "Hallo1")) (funcall this-shell-command "echo foo >&2; echo bar" (current-buffer) stderr) - (when (getenv "EMACS_EMBA_CI") - (tramp--test-message "Hallo2")) (should (string-equal "bar\n" (buffer-string))) - (when (getenv "EMACS_EMBA_CI") - (tramp--test-message "Hallo3")) ;; Check stderr. (should - (string-equal "foo\n" (tramp-get-buffer-string stderr))) - (when (getenv "EMACS_EMBA_CI") - (tramp--test-message "Hallo4"))) + (string-equal "foo\n" (tramp-get-buffer-string stderr)))) ;; Cleanup. (ignore-errors (kill-buffer stderr)))))) @@ -5454,7 +5445,7 @@ INPUT, if non-nil, is a string sent to the process." (read (tramp--test-shell-command-to-string-asynchronously "tput cols"))))) (when (natnump cols) - (should (= cols async-shell-command-width))))))) + (should (= cols async-shell-command-width)))))) (tramp--test-deftest-direct-async-process tramp-test32-shell-command 'unstable) commit 4a1c7a90edcb0c5e8beed6d649472f1bef59b389 Author: Michael Albinus Date: Wed Jul 27 19:55:18 2022 +0200 * lisp/net/tramp.el (tramp-handle-shell-command): Modify sentinel handling. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 0bfb770f5e..e1a45e4ad5 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -4865,11 +4865,13 @@ support symbolic links." (error-file (and error-buffer (with-parsed-tramp-file-name default-directory nil - (tramp-test-message "Holla1") + (when (getenv "EMACS_EMBA_CI") + (tramp-test-message "Holla1")) (prog1 (tramp-make-tramp-file-name v (tramp-make-tramp-temp-file v)) - (tramp-test-message "Holla2"))))) + (when (getenv "EMACS_EMBA_CI") + (tramp-test-message "Holla2")))))) (bname (buffer-name output-buffer)) (p (get-buffer-process output-buffer)) (dir default-directory) @@ -4940,33 +4942,39 @@ support symbolic links." ;; Run the process. (setq p (start-file-process-shell-command (buffer-name output-buffer) buffer command)) - ;; Insert error messages if they were separated. - (when error-file - (tramp-test-message "Holla3") - (with-current-buffer error-buffer - (insert-file-contents-literally error-file)) - (tramp-test-message "Holla4")) - (if (process-live-p p) - ;; Display output. - (with-current-buffer output-buffer - (setq mode-line-process '(":%s")) - (unless (eq major-mode 'shell-mode) - (shell-mode)) - (set-process-filter p #'comint-output-filter) - (set-process-sentinel p #'shell-command-sentinel) - (when error-file - (add-function - :after (process-sentinel p) - (lambda (_proc _string) - (with-current-buffer error-buffer - (insert-file-contents-literally - error-file nil nil nil 'replace)) - (delete-file error-file)))) - (display-buffer output-buffer '(nil (allow-no-window . t)))) - - (when error-file - (delete-file error-file))))) - + (when (process-live-p p) + ;; Display output. + (with-current-buffer output-buffer + (setq mode-line-process '(":%s")) + (unless (eq major-mode 'shell-mode) + (shell-mode)) + (set-process-filter p #'comint-output-filter) + (set-process-sentinel p #'shell-command-sentinel) + (when error-file + (add-function + :after (process-sentinel p) + (lambda (_proc _string) + (when (getenv "EMACS_EMBA_CI") + (tramp-test-message "Holla3 %s" error-file)) + (with-current-buffer error-buffer + (insert-file-contents-literally + error-file nil nil nil 'replace)) + (when (getenv "EMACS_EMBA_CI") + (tramp-test-message "Holla4 %s" error-file)) + (delete-file error-file)))) + (display-buffer output-buffer '(nil (allow-no-window . t)))) + + ;; Insert error messages if they were separated. + (when (and error-file (not (process-live-p p))) + (when (getenv "EMACS_EMBA_CI") + (tramp-test-message "Holla5 %s" error-file)) + (with-current-buffer error-buffer + (insert-file-contents-literally error-file)) + (when (getenv "EMACS_EMBA_CI") + (tramp-test-message "Holla6 %s" error-file)) + (delete-file error-file))))) + + ;; Synchronous case. (prog1 ;; Run the process. (process-file-shell-command command nil buffer) commit cc6aebc85eb1a139dcdff45870cda062b7f94596 Author: Michael Albinus Date: Wed Jul 27 15:22:08 2022 +0200 Further Tramp instrumentation ; * test/infra/test-jobs.yml (test-lisp-net-inotify): ; Revert instrumentation. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index c123b2eac1..0bfb770f5e 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -4865,8 +4865,11 @@ support symbolic links." (error-file (and error-buffer (with-parsed-tramp-file-name default-directory nil - (tramp-make-tramp-file-name - v (tramp-make-tramp-temp-file v))))) + (tramp-test-message "Holla1") + (prog1 + (tramp-make-tramp-file-name + v (tramp-make-tramp-temp-file v)) + (tramp-test-message "Holla2"))))) (bname (buffer-name output-buffer)) (p (get-buffer-process output-buffer)) (dir default-directory) @@ -4939,25 +4942,27 @@ support symbolic links." (buffer-name output-buffer) buffer command)) ;; Insert error messages if they were separated. (when error-file + (tramp-test-message "Holla3") (with-current-buffer error-buffer - (insert-file-contents-literally error-file))) + (insert-file-contents-literally error-file)) + (tramp-test-message "Holla4")) (if (process-live-p p) - ;; Display output. - (with-current-buffer output-buffer - (setq mode-line-process '(":%s")) - (unless (eq major-mode 'shell-mode) - (shell-mode)) - (set-process-filter p #'comint-output-filter) - (set-process-sentinel p #'shell-command-sentinel) - (when error-file - (add-function - :after (process-sentinel p) - (lambda (_proc _string) - (with-current-buffer error-buffer - (insert-file-contents-literally - error-file nil nil nil 'replace)) - (delete-file error-file)))) - (display-buffer output-buffer '(nil (allow-no-window . t)))) + ;; Display output. + (with-current-buffer output-buffer + (setq mode-line-process '(":%s")) + (unless (eq major-mode 'shell-mode) + (shell-mode)) + (set-process-filter p #'comint-output-filter) + (set-process-sentinel p #'shell-command-sentinel) + (when error-file + (add-function + :after (process-sentinel p) + (lambda (_proc _string) + (with-current-buffer error-buffer + (insert-file-contents-literally + error-file nil nil nil 'replace)) + (delete-file error-file)))) + (display-buffer output-buffer '(nil (allow-no-window . t)))) (when error-file (delete-file error-file))))) diff --git a/test/infra/test-jobs.yml b/test/infra/test-jobs.yml index c18a3ca0d9..51707c181b 100644 --- a/test/infra/test-jobs.yml +++ b/test/infra/test-jobs.yml @@ -338,7 +338,7 @@ test-lisp-net-inotify: - test/lisp/net/*resources/** variables: target: emacs-inotify - make_params: "-k -C test check-lisp-net SELECTOR='(not (tag :unstable))'" + make_params: "-k -C test check-lisp-net" test-lisp-nxml-inotify: stage: normal diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index b064e3f5d0..9f88b5d5d3 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -5349,7 +5349,7 @@ INPUT, if non-nil, is a string sent to the process." (ert-deftest tramp-test32-shell-command () "Check `shell-command'." - :tags '(:expensive-test) + :tags (unless (getenv "EMACS_EMBA_CI") '(:expensive-test)) (skip-unless (tramp--test-enabled)) (skip-unless (tramp--test-supports-processes-p)) ;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for commit 35435b86f9ba1958b972571d5c00f4819f72c39c Author: Mattias EngdegĂ„rd Date: Wed Jul 27 14:34:00 2022 +0200 ; * etc/NEWS: typo diff --git a/etc/NEWS b/etc/NEWS index b79e216aa0..8ca2e51e28 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2418,7 +2418,7 @@ but switching to `ash` is generally much preferable. 'vc-arch-command'. +++ -** New generic function 'function-doumentation'. +** New generic function 'function-documentation'. Can dynamically generate a raw docstring depending on the type of a function. Used mainly for docstrings of OClosures. commit f6b6614c32f73b0bde3121d39fdfb1d302a97bd8 Author: F. Jason Park Date: Fri Jul 8 04:58:26 2022 -0700 Add compat from GNU ELPA as a soft dependency in ERC * lisp/erc/erc-backend.el (erc-parse-server-response, erc--parse-isupport-value): Remove sub-28 compat code involving `string-search'. * lisp/erc/erc-compat.el: Require compat package, but don't error when absent. * lisp/erc/erc-dcc.el (erc-dcc-member): Remove `string-search' compat code. (erc-dcc-unquote-filename): Remove `string-replace' compat code. * lisp/erc/erc-speedbar.el (erc-speedbar-expand-server, erc-speedbar-expand-channel, erc-speedbar-expand-user): Remove `string-search' compat code. * lisp/erc/erc.el: Add compat version 28.1.2.0 to Package-Requires header and require `erc-compat' after other libraries. (erc--valid-local-channel-p): Remove `string-search' compat code. (erc-update-mode-line-buffer): Remove `string-replace' compat code. (erc-message-english-PART): Remove `string-replace' compat code. diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index f83c27dc4e..df9efe4b0c 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -1011,21 +1011,15 @@ PROCs `process-buffer' is `current-buffer' when this function is called." (save-match-data (let* ((tag-list (when (eq (aref string 0) ?@) (substring string 1 - (if (>= emacs-major-version 28) - (string-search " " string) - (string-match " " string))))) + (string-search " " string)))) (msg (make-erc-response :unparsed string :tags (when tag-list (erc-parse-tags tag-list)))) (string (if tag-list - (substring string (+ 1 (if (>= emacs-major-version 28) - (string-search " " string) - (string-match " " string)))) + (substring string (+ 1 (string-search " " string))) string)) (posn (if (eq (aref string 0) ?:) - (if (>= emacs-major-version 28) - (string-search " " string) - (string-match " " string)) + (string-search " " string) 0))) (setf (erc-response.sender msg) @@ -1035,9 +1029,7 @@ PROCs `process-buffer' is `current-buffer' when this function is called." (setf (erc-response.command msg) (let* ((bposn (string-match "[^ \n]" string posn)) - (eposn (if (>= emacs-major-version 28) - (string-search " " string bposn) - (string-match " " string bposn)))) + (eposn (string-search " " string bposn))) (setq posn (and eposn (string-match "[^ \n]" string eposn))) (substring string bposn eposn))) @@ -1045,9 +1037,7 @@ PROCs `process-buffer' is `current-buffer' when this function is called." (while (and posn (not (eq (aref string posn) ?:))) (push (let* ((bposn posn) - (eposn (if (>= emacs-major-version 28) - (string-search " " string bposn) - (string-match " " string bposn)))) + (eposn (string-search " " string bposn))) (setq posn (and eposn (string-match "[^ \n]" string eposn))) (substring string bposn eposn)) @@ -1668,9 +1658,7 @@ Then display the welcome message." start (- (match-end 0) 3)) (setq start (match-end 0)))) v)) - (if (if (>= emacs-major-version 28) - (string-search "," value) - (string-match-p "," value)) + (if (string-search "," value) (split-string value ",") (list value))))) diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index 16cfb15a5a..8a00e711ac 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -25,8 +25,14 @@ ;; This mostly defines stuff that cannot be worked around easily. +;; ERC depends on the `compat' library from GNU ELPA for supporting +;; older versions of Emacs. See this discussion for additional info: +;; https://lists.gnu.org/archive/html/emacs-devel/2022-07/msg00512.html + ;;; Code: +(require 'compat nil 'noerror) + ;;;###autoload(autoload 'erc-define-minor-mode "erc-compat") (define-obsolete-function-alias 'erc-define-minor-mode #'define-minor-mode "28.1") diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el index 5862fba3b8..977080a4de 100644 --- a/lisp/erc/erc-dcc.el +++ b/lisp/erc/erc-dcc.el @@ -191,9 +191,7 @@ compared with `erc-nick-equal-p' which is IRC case-insensitive." test (cadr (plist-member elt prop))) ;; if the property exists and is equal, we continue, else, try the ;; next element of the list - (or (and (eq prop :nick) (if (>= emacs-major-version 28) - (string-search "!" val) - (string-match "!" val)) + (or (and (eq prop :nick) (string-search "!" val) test (string-equal test val)) (and (eq prop :nick) test val @@ -659,13 +657,7 @@ that subcommand." (define-inline erc-dcc-unquote-filename (filename) (inline-quote - (if (>= emacs-major-version 28) - (string-replace - "\\\\" "\\" - (string-replace "\\\"" "\"" ,filename)) - (replace-regexp-in-string - "\\\\\\\\" "\\" - (replace-regexp-in-string "\\\\\"" "\"" ,filename t t) t t)))) + (string-replace "\\\\" "\\" (string-replace "\\\"" "\"" ,filename)))) (defun erc-dcc-handle-ctcp-send (proc query nick login host to) "This is called if a CTCP DCC SEND subcommand is sent to the client. diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el index 5b06c21612..19113c5aad 100644 --- a/lisp/erc/erc-speedbar.el +++ b/lisp/erc/erc-speedbar.el @@ -139,9 +139,7 @@ This will add a speedbar major display mode." t)))) (defun erc-speedbar-expand-server (text server indent) - (cond ((if (>= emacs-major-version 28) - (string-search "+" text) - (string-match "\\+" text)) + (cond ((string-search "+" text) (speedbar-change-expand-button-char ?-) (if (speedbar-with-writable (save-excursion @@ -150,9 +148,7 @@ This will add a speedbar major display mode." (speedbar-change-expand-button-char ?-) (speedbar-change-expand-button-char ??))) (;; we have to contract this node - (if (>= emacs-major-version 28) - (string-search "-" text) - (string-match "-" text)) + (string-search "-" text) (speedbar-change-expand-button-char ?+) (speedbar-delete-subblock indent)) (t (error "Ooops... not sure what to do"))) @@ -189,9 +185,7 @@ This will add a speedbar major display mode." "For the line matching TEXT, in CHANNEL, expand or contract a line. INDENT is the current indentation level." (cond - ((if (>= emacs-major-version 28) - (string-search "+" text) - (string-match "\\+" text)) + ((string-search "+" text) (speedbar-change-expand-button-char ?-) (speedbar-with-writable (save-excursion @@ -240,9 +234,7 @@ INDENT is the current indentation level." (speedbar-with-writable (dolist (entry names) (erc-speedbar-insert-user entry ?+ (1+ indent)))))))))) - ((if (>= emacs-major-version 28) - (string-search "-" text) - (string-match "-" text)) + ((string-search "-" text) (speedbar-change-expand-button-char ?+) (speedbar-delete-subblock indent)) (t (error "Ooops... not sure what to do"))) @@ -293,9 +285,7 @@ The update is only done when the channel is actually expanded already." (erc-speedbar-expand-channel "+" buffer 1))))) (defun erc-speedbar-expand-user (text token indent) - (cond ((if (>= emacs-major-version 28) - (string-search "+" text) - (string-match "\\+" text)) + (cond ((string-search "+" text) (speedbar-change-expand-button-char ?-) (speedbar-with-writable (save-excursion @@ -318,9 +308,7 @@ The update is only done when the channel is actually expanded already." nil nil nil nil info nil nil nil (1+ indent))))))) - ((if (>= emacs-major-version 28) - (string-search "-" text) - (string-match "-" text)) + ((string-search "-" text) (speedbar-change-expand-button-char ?+) (speedbar-delete-subblock indent)) (t (error "Ooops... not sure what to do"))) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 3b127bbd49..151d75e7ce 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -13,7 +13,7 @@ ;; Michael Olson (mwolson@gnu.org) ;; Kelvin White (kwhite@gnu.org) ;; Version: 5.4.1 -;; Package-Requires: ((emacs "27.1")) +;; Package-Requires: ((emacs "27.1") (compat "28.1.2.0")) ;; Keywords: IRC, chat, client, Internet ;; URL: https://www.gnu.org/software/emacs/erc.html @@ -69,6 +69,8 @@ (require 'iso8601) (eval-when-compile (require 'subr-x)) +(require 'erc-compat) + (defconst erc-version "5.4.1" "This version of ERC.") @@ -3519,9 +3521,7 @@ Without SECRET, consult auth-source, possibly passing SERVER as the "Non-nil when channel is server-local on a network that allows them." (and-let* (((eq ?& (aref channel 0))) (chan-types (erc--get-isupport-entry 'CHANTYPES 'single)) - ((if (>= emacs-major-version 28) - (string-search "&" chan-types) - (string-match-p "&" chan-types)))))) + ((string-search "&" chan-types))))) (defun erc-cmd-JOIN (channel &optional key) "Join the channel given in CHANNEL, optionally with KEY. @@ -7005,21 +7005,12 @@ shortened server name instead." (fill-region (point-min) (point-max)) (buffer-string)))) (setq header-line-format - (if (>= emacs-major-version 28) - (string-replace - "%" - "%%" - (if face - (propertize header 'help-echo help-echo - 'face face) - (propertize header 'help-echo help-echo))) - (replace-regexp-in-string - "%" - "%%" - (if face - (propertize header 'help-echo help-echo - 'face face) - (propertize header 'help-echo help-echo))))))) + (string-replace + "%" + "%%" + (if face + (propertize header 'help-echo help-echo 'face face) + (propertize header 'help-echo help-echo)))))) (t (setq header-line-format (if face (propertize header 'face face) @@ -7304,9 +7295,7 @@ functions." nick user host channel (if (not (string= reason "")) (format ": %s" - (if (>= emacs-major-version 28) - (string-replace "%" "%%" reason) - (replace-regexp-in-string "%" "%%" reason))) + (string-replace "%" "%%" reason)) ""))))) commit c238f568cddc0502feb058e651907a1baaed3149 Author: F. Jason Park Date: Wed Jul 6 00:40:42 2022 -0700 Avoid mutating default value of erc-server-last-peers * lisp/erc/erc-backend.el (erc-server-last-peers): Leave default as nil instead of a quoted constant. (erc-server-connect): Initialize `erc-server-last-peers' to a new value local to a server buffer. (erc-message): Operate on server's local `erc-server-last-peers' value instead of the global default. Prefer replacing value instead of mutating CDR to make for easier testing. (erc-server-PRIVMSG): Create a new `erc-server-last-peers' for easier testing. (Bug#56449) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 46c96c1a74..f83c27dc4e 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -230,7 +230,7 @@ current IRC process is still alive.") (defvar-local erc-server-lines-sent nil "Line counter.") -(defvar-local erc-server-last-peers '(nil . nil) +(defvar-local erc-server-last-peers nil "Last peers used, both sender and receiver. Those are used for /MSG destination shortcuts.") @@ -562,7 +562,7 @@ TLS (see `erc-session-client-certificate' for more details)." (setq erc-server-last-received-time time)) (setq erc-server-lines-sent 0) ;; last peers (sender and receiver) - (setq erc-server-last-peers '(nil . nil))) + (setq erc-server-last-peers (cons nil nil))) ;; we do our own encoding and decoding (when (fboundp 'set-process-coding-system) (set-process-coding-system process 'raw-text)) @@ -939,21 +939,20 @@ be used. If the target is \".\", the last person you've sent a message to will be used." (cond ((string-match "^\\s-*\\(\\S-+\\) ?\\(.*\\)" line) - (let ((tgt (match-string 1 line)) - (s (match-string 2 line))) + (let* ((tgt (match-string 1 line)) + (s (match-string 2 line)) + (server-buffer (erc-server-buffer)) + (peers (buffer-local-value 'erc-server-last-peers server-buffer))) (erc-log (format "cmd: MSG(%s): [%s] %s" message-command tgt s)) (cond ((string= tgt ",") - (if (car erc-server-last-peers) - (setq tgt (car erc-server-last-peers)) - (setq tgt nil))) + (setq tgt (car peers))) ((string= tgt ".") - (if (cdr erc-server-last-peers) - (setq tgt (cdr erc-server-last-peers)) - (setq tgt nil)))) + (setq tgt (cdr peers)))) (cond (tgt - (setcdr erc-server-last-peers tgt) + (with-current-buffer server-buffer + (setq erc-server-last-peers (cons (car peers) tgt))) (erc-server-send (format "%s %s :%s" message-command tgt s) force)) (t @@ -1552,7 +1551,7 @@ add things to `%s' instead." (erc-process-ctcp-reply proc parsed nick login host (match-string 1 msg))))) (t - (setcar erc-server-last-peers nick) + (setq erc-server-last-peers (cons nick (cdr erc-server-last-peers))) (setq s (erc-format-privmessage (or fnick nick) msg ;; If buffer is a query buffer, diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 4971d0e194..0f222edacf 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -893,4 +893,86 @@ (should-not calls)))))) +;; Note: if adding an erc-backend-tests.el, please relocate this there. + +(ert-deftest erc-message () + (should-not erc-server-last-peers) + (let (server-proc + calls + erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook) + (cl-letf (((symbol-function 'erc-display-message) + (lambda (_ _ _ line) (push line calls))) + ((symbol-function 'erc-server-send) + (lambda (line _) (push line calls))) + ((symbol-function 'erc-server-buffer) + (lambda () (process-buffer server-proc)))) + (with-current-buffer (get-buffer-create "ExampleNet") + (erc-mode) + (setq erc-server-current-nick "tester" + server-proc (start-process "sleep" (current-buffer) "sleep" "1") + erc-server-process server-proc + erc-server-last-peers (cons nil nil) + erc-server-users (make-hash-table :test 'equal) + erc-network 'ExampleNet) + (set-process-query-on-exit-flag erc-server-process nil)) + + (with-current-buffer (get-buffer-create "#chan") + (erc-mode) + (setq erc-server-process (buffer-local-value 'erc-server-process + (get-buffer "ExampleNet")) + erc-default-recipients '("#chan") + erc-channel-users (make-hash-table :test 'equal) + erc-network 'ExampleNet) + (erc-update-current-channel-member "alice" "alice") + (erc-update-current-channel-member "tester" "tester")) + + (with-current-buffer "ExampleNet" + (erc-server-PRIVMSG erc-server-process + (make-erc-response + :sender "alice!~u@fsf.org" + :command "PRIVMSG" + :command-args '("#chan" "hi") + :unparsed ":alice!~u@fsf.org PRIVMSG #chan :hi")) + (should (equal erc-server-last-peers '("alice"))) + (should (string-match "" (pop calls)))) + + (with-current-buffer "#chan" + (ert-info ("Shortcuts usable in target buffers") + (should-not (local-variable-p 'erc-server-last-peers)) + (should-not erc-server-last-peers) + (erc-message "PRIVMSG" ". hi") + (should-not erc-server-last-peers) + (should (eq 'no-target (pop calls))) + (erc-message "PRIVMSG" ", hi") + (should-not erc-server-last-peers) + (should (string-match "alice :hi" (pop calls))))) + + (with-current-buffer "ExampleNet" + (ert-info ("Shortcuts local in server bufs") + (should (equal erc-server-last-peers '("alice" . "alice"))) + (erc-message "PRIVMSG" ", hi") + (should (equal erc-server-last-peers '("alice" . "alice"))) + (should (string-match "PRIVMSG alice :hi" (pop calls))) + (setcdr erc-server-last-peers "bob") + (erc-message "PRIVMSG" ". hi") + (should (equal erc-server-last-peers '("alice" . "bob"))) + (should (string-match "PRIVMSG bob :hi" (pop calls))))) + + (with-current-buffer "#chan" + (ert-info ("Non-shortcuts are local to server buffer") + (should-not (local-variable-p 'erc-server-last-peers)) + (should-not erc-server-last-peers) + (erc-message "PRIVMSG" "#chan hola") + (should-not erc-server-last-peers) + (should-not (default-value 'erc-server-last-peers)) + (should (equal (buffer-local-value 'erc-server-last-peers + (get-buffer "ExampleNet")) + '("alice" . "#chan"))) + (should (string-match "hola" (pop calls)))))) + + (should-not erc-server-last-peers) + (should-not calls) + (kill-buffer "ExampleNet") + (kill-buffer "#chan"))) + ;;; erc-tests.el ends here commit 075d6bb41089a7ea4bb5353dd70448ed5653261c Author: F. Jason Park Date: Sun Jul 24 05:14:24 2022 -0700 Ensure erc-dcc-chat-setup runs in the right buffer * lisp/erc/erc-dcc.el (erc-dcc-chat-setup): Ensure initialization runs in the intended buffer regardless of the value of `erc-join-buffer'. (erc-dcc--send-final-turbo-ack, erc-dcc-get-filter): Rename internal variable formerly known as `erc-dcc--X-send-final-turbo-ack'. diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el index d0e1848e0e..5862fba3b8 100644 --- a/lisp/erc/erc-dcc.el +++ b/lisp/erc/erc-dcc.el @@ -987,7 +987,7 @@ The contents of the BUFFER will then be erased." ;; If people really need this, we can convert it into a proper option. -(defvar erc-dcc--X-send-final-turbo-ack nil +(defvar erc-dcc--send-final-turbo-ack nil "Workaround for maverick turbo senders that only require a final ACK. The only known culprit is WeeChat, with its xfer.network.fast_send option, which is on by default. Leaving this set to nil and calling @@ -1032,7 +1032,7 @@ rather than every 1024 byte block, but nobody seems to care." ;; Some senders want us to hang up. Only observed w. TSEND. ((and (plist-get erc-dcc-entry-data :turbo) (= received-bytes (plist-get erc-dcc-entry-data :size))) - (when erc-dcc--X-send-final-turbo-ack + (when erc-dcc--send-final-turbo-ack (process-send-string proc (erc-pack-int received-bytes))) (delete-process proc)) ((not (or (plist-get erc-dcc-entry-data :turbo) @@ -1182,18 +1182,18 @@ other client." (proc (plist-get entry :peer)) (parent-proc (plist-get entry :parent))) (erc-setup-buffer buffer) - ;; buffer is now the current buffer. - (erc-dcc-chat-mode) - (setq erc-server-process parent-proc) - (setq erc-dcc-from nick) - (setq erc-dcc-entry-data entry) - (setq erc-dcc-unprocessed-output "") - (setq erc-insert-marker (point-max-marker)) - (setq erc-input-marker (make-marker)) - (erc-display-prompt buffer (point-max)) - (set-process-buffer proc buffer) - (add-hook 'kill-buffer-hook #'erc-dcc-chat-buffer-killed nil t) - (run-hook-with-args 'erc-dcc-chat-connect-hook proc) + (with-current-buffer buffer + (erc-dcc-chat-mode) + (setq erc-server-process parent-proc + erc-dcc-from nick + erc-dcc-entry-data entry + erc-dcc-unprocessed-output "" + erc-insert-marker (point-max-marker) + erc-input-marker (make-marker)) + (erc-display-prompt buffer (point-max)) + (set-process-buffer proc buffer) + (add-hook 'kill-buffer-hook #'erc-dcc-chat-buffer-killed nil t) + (run-hook-with-args 'erc-dcc-chat-connect-hook proc)) buffer)) (defun erc-dcc-chat-accept (entry parent-proc) commit 4a5499910a114a5e8a8b41e04397c20dec14935b Author: F. Jason Park Date: Sun Jul 24 05:14:24 2022 -0700 Fix CTCP regression in erc-server-PRIVMSG * lisp/erc/erc-backend.el (erc-server-PRIVMSG): Don't create a query buffer for non-ACTION CTCP messages. * test/lisp/erc/erc-scenarios-misc.el (erc-scenarios-dcc-chat-accept): Add test for basic DCC CHAT accept dialog. * test/lisp/erc/resources/dcc/chat/accept-dcc.eld: New file. * test/lisp/erc/resources/dcc/chat/accept.eld: New file. diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 8be4894ecb..46c96c1a74 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -1526,11 +1526,13 @@ add things to `%s' instead." (setf (erc-response.contents parsed) msg) (setq buffer (erc-get-buffer (if privp nick tgt) proc)) ;; Even worth checking for empty target here? (invalid anyway) - (unless (or buffer noticep (string-empty-p tgt) (eq ?$ (aref tgt 0))) - (if (and privp msgp (not (erc-is-message-ctcp-and-not-action-p msg))) + (unless (or buffer noticep (string-empty-p tgt) (eq ?$ (aref tgt 0)) + (erc-is-message-ctcp-and-not-action-p msg)) + (if privp (when erc-auto-query (let ((erc-join-buffer erc-auto-query)) (setq buffer (erc--open-target nick)))) + ;; A channel buffer has been killed but is still joined (setq buffer (erc--open-target tgt)))) (when buffer (with-current-buffer buffer diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 4b852b3904..3b127bbd49 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -4654,8 +4654,9 @@ a new window, but not to select it. See the documentation for (const :tag "Use current buffer" buffer) (const :tag "Use current buffer" t))) -;; FIXME either retire this or put it to use or more clearly explain -;; what it's supposed to do. It's currently only used by the obsolete +;; FIXME either retire this or put it to use after determining how +;; it's meant to work. Clearly, the doc string does not describe +;; current behavior. It's currently only used by the obsolete ;; function `erc-auto-query'. (defcustom erc-query-on-unjoined-chan-privmsg t "If non-nil create query buffer on receiving any PRIVMSG at all. diff --git a/test/lisp/erc/erc-scenarios-misc.el b/test/lisp/erc/erc-scenarios-misc.el index 9d6d5bc1d6..ded620ccc1 100644 --- a/test/lisp/erc/erc-scenarios-misc.el +++ b/test/lisp/erc/erc-scenarios-misc.el @@ -138,4 +138,43 @@ (should-not (get-buffer "$*")))) +(ert-deftest erc-scenarios-dcc-chat-accept () + :tags '(:expensive-test) + (erc-scenarios-common-with-cleanup + ((erc-scenarios-common-dialog "dcc/chat") + (dcc-server (erc-d-run "127.0.0.1" t "erc-dcc-server" 'accept-dcc + :ending "\n")) + (dcc-port (process-contact dcc-server :service)) + (dumb-server (erc-d-run "localhost" t 'accept :tmpl-vars + `((port . ,(number-to-string dcc-port))))) + (port (process-contact dumb-server :service)) + (expect (erc-d-t-make-expecter))) + + (ert-info ("Connect to foonet") + (with-current-buffer (erc :server "127.0.0.1" + :port port + :nick "tester" + :password "changeme" + :full-name "tester") + (should (string= (buffer-name) (format "127.0.0.1:%d" port))))) + + (ert-info ("Offer received") + (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "foonet")) + (funcall expect 10 "DCC: chat offered by dummy") + (erc-cmd-DCC "CHAT" "dummy"))) + + ;; Regression + (erc-d-t-ensure-for 1 (not (get-buffer "tester"))) + + ;; Becomes current buffer by default (because `erc-join-buffer') + (erc-d-t-wait-for 10 (get-buffer "DCC-CHAT-dummy")) + + (with-current-buffer "foonet" + (funcall expect 10 "*** DCC: accepting chat from dummy")) + + (ert-info ("Chat with dummy") + (with-current-buffer "DCC-CHAT-dummy" + (erc-scenarios-common-say "Hi") + (funcall expect 10 "Hola"))))) + ;;; erc-scenarios-misc.el ends here diff --git a/test/lisp/erc/resources/dcc/chat/accept-dcc.eld b/test/lisp/erc/resources/dcc/chat/accept-dcc.eld new file mode 100644 index 0000000000..23828a8115 --- /dev/null +++ b/test/lisp/erc/resources/dcc/chat/accept-dcc.eld @@ -0,0 +1,3 @@ +;; -*- mode: lisp-data; -*- +((open 10 "Hi") + (0 "Hola")) diff --git a/test/lisp/erc/resources/dcc/chat/accept.eld b/test/lisp/erc/resources/dcc/chat/accept.eld new file mode 100644 index 0000000000..a23e9580bc --- /dev/null +++ b/test/lisp/erc/resources/dcc/chat/accept.eld @@ -0,0 +1,23 @@ +;; -*- mode: lisp-data; -*- +((pass 1 "PASS :changeme")) +((nick 1 "NICK tester")) +((user 1 "USER user 0 * :tester") + (0 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester") + (0 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version oragono-2.6.0-7481bf0385b95b16") + (0 ":irc.foonet.org 003 tester :This server was created Mon, 31 May 2021 09:56:24 UTC") + (0 ":irc.foonet.org 004 tester irc.foonet.org oragono-2.6.0-7481bf0385b95b16 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv") + (0 ":irc.foonet.org 005 tester AWAYLEN=390 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server") + (0 ":irc.foonet.org 005 tester MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=foonet NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY WHOX :are supported by this server") + (0 ":irc.foonet.org 005 tester draft/CHATHISTORY=100 :are supported by this server") + (0 ":irc.foonet.org 251 tester :There are 0 users and 4 invisible on 1 server(s)") + (0 ":irc.foonet.org 252 tester 0 :IRC Operators online") + (0 ":irc.foonet.org 254 tester 2 :channels formed") + (0 ":irc.foonet.org 255 tester :I have 4 clients and 0 servers") + (0 ":irc.foonet.org 265 tester 4 4 :Current local users 4, max 4") + (0 ":irc.foonet.org 266 tester 4 4 :Current global users 4, max 4") + (0 ":irc.foonet.org 422 tester :MOTD File is missing")) + +((mode-user 1.2 "MODE tester +i") + ;; No mode answer + (0 ":irc.foonet.org NOTICE tester :This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect.") + (0.2 ":dummy!~u@34n9brushbpj2.irc PRIVMSG tester :\C-aDCC CHAT chat 2130706433 " port "\C-a")) commit 69f578e04712616f91080ab26485db9faacb3a70 Author: F. Jason Park Date: Sun Jul 24 05:14:24 2022 -0700 Allow non-IRC line delimiters with ERC test server * test/lisp/erc/resources/erc-d/erc-d.el (erc-d-server-fqdn, erc-d--initialize-client, erc-d--log, erc-d--send, erc-d--filter, erc-d-run): Add new variable and use it. Also optionally accept keyword arguments in `erc-d-run'. * test/lisp/erc/resources/erc-d/erc-d-tests.el (erc-d-run-direct-foreign-protocol): Add test demoing newline-only line-wise protocol. * test/lisp/erc/resources/erc-d/resources/foreign.eld: New file. diff --git a/test/lisp/erc/resources/erc-d/erc-d-tests.el b/test/lisp/erc/resources/erc-d/erc-d-tests.el index 21005cd760..357bc48b08 100644 --- a/test/lisp/erc/resources/erc-d/erc-d-tests.el +++ b/test/lisp/erc/resources/erc-d/erc-d-tests.el @@ -1343,4 +1343,31 @@ DIALOGS are symbols representing the base names of dialog files in (kill-buffer dumb-server-buffer))) (delete-file sock)))) +(ert-deftest erc-d-run-direct-foreign-protocol () + :tags '(:expensive-test) + (let* ((server (erc-d-run "localhost" t "erc-d-server" 'foreign + :ending "\n")) + (server-buffer (get-buffer "*erc-d-server*")) + (client-buffer (get-buffer-create "*erc-d-client*")) + client) + (with-current-buffer server-buffer (erc-d-t-search-for 4 "Starting")) + (setq client (make-network-process + :buffer client-buffer + :name "erc-d-client" + :family 'ipv4 + :noquery t + :coding 'binary + :service (process-contact server :service) + :host "localhost")) + (process-send-string client "ONE one\n") + (with-current-buffer client-buffer + (erc-d-t-search-for 5 "echo ONE one")) + (process-send-string client "TWO two\n") + (with-current-buffer client-buffer + (erc-d-t-search-for 2 "echo TWO two")) + (erc-d-t-wait-for 2 "server death" (not (process-live-p server))) + (when noninteractive + (kill-buffer client-buffer) + (kill-buffer server-buffer)))) + ;;; erc-d-tests.el ends here diff --git a/test/lisp/erc/resources/erc-d/erc-d.el b/test/lisp/erc/resources/erc-d/erc-d.el index ee9b6a7fec..d6082227c5 100644 --- a/test/lisp/erc/resources/erc-d/erc-d.el +++ b/test/lisp/erc/resources/erc-d/erc-d.el @@ -136,6 +136,9 @@ Only relevant when starting a server with `erc-d-run'.") Possibly used by overriding handlers, like the one for PING, and/or dialog templates for the sender portion of a reply message.") +(defvar erc-d-line-ending "\r\n" + "Protocol line delimiter for sending and receiving.") + (defvar erc-d-linger-secs nil "Seconds to wait before quitting for all dialogs. For more granular control, use the provided LINGER `rx' variable (alone) @@ -249,6 +252,7 @@ return a replacement.") (mat-h (copy-sequence (process-get process :dialog-match-handlers))) (fqdn (copy-sequence (process-get process :dialog-server-fqdn))) (vars (copy-sequence (process-get process :dialog-vars))) + (ending (process-get process :dialog-ending)) (dialog (make-erc-d-dialog :name name :process process :queue (make-ring 5) @@ -263,6 +267,8 @@ return a replacement.") (erc-d-dialog-hunks dialog) reader) ;; Add reverse link, register client, launch (process-put process :dialog dialog) + (process-put process :ending ending) + (process-put process :ending-regexp (rx-to-string `(+ ,ending))) (push process erc-d--clients) (erc-d--command-refresh dialog nil) (erc-d--on-request process))) @@ -311,7 +317,7 @@ PROCESS should be a client connection or a server network process." (name (erc-d-dialog-name (process-get ,process :dialog)))) (if ,outbound (erc-d--m process "-> %s:%s %s" name id ,string) - (dolist (line (split-string ,string "\r\n")) + (dolist (line (split-string ,string (process-get process :ending))) (erc-d--m process "<- %s:%s %s" name id line))))) (defun erc-d--log-process-event (server process msg) @@ -320,7 +326,7 @@ PROCESS should be a client connection or a server network process." (defun erc-d--send (process string) "Send STRING to PROCESS peer." (erc-d--log process string 'outbound) - (process-send-string process (concat string "\r\n"))) + (process-send-string process (concat string (process-get process :ending)))) (define-inline erc-d--fuzzy-p (exchange) (inline-letevals (exchange) @@ -442,9 +448,10 @@ This will start the teardown for DIALOG." "Handle input received from peer. PROCESS represents a client peer connection and STRING is a raw request including line delimiters." - (let ((queue (erc-d-dialog-queue (process-get process :dialog)))) + (let ((queue (erc-d-dialog-queue (process-get process :dialog))) + (delim (process-get process :ending-regexp))) (setq string (concat (process-get process :stashed-input) string)) - (while (and string (string-match (rx (+ "\r\n")) string)) + (while (and string (string-match delim string)) (let ((line (substring string 0 (match-beginning 0)))) (setq string (unless (= (match-end 0) (length string)) (substring string (match-end 0)))) @@ -913,35 +920,40 @@ Pass HOST and SERVICE directly to `make-network-process'. When present, use string SERVER-NAME for the server-process name as well as that of its buffer (w. surrounding asterisks). When absent, do the same with `erc-d-server-name'. When running \"in process,\" return the server -process, otherwise sleep for the duration of the server process. +process; otherwise sleep until it dies. A dialog must be a symbol matching the base name of a dialog file in -`erc-d-u-canned-dialog-dir'. - -The variable `erc-d-tmpl-vars' determines the common members of the -`erc-d--render-entries' ENTRIES param. Variables `erc-d-server-fqdn' -and `erc-d-linger-secs' determine the `erc-d-dialog' items -`:server-fqdn' and `:linger-secs' for all client processes. - -The variable `erc-d-tmpl-vars' can be used to initialize the -process's `erc-d-dialog' vars item." +`erc-d-u-canned-dialog-dir'. Global variables `erc-d-server-fqdn', +`erc-d-linger-secs', and `erc-d-tmpl-vars' determine the process's +`erc-d-dialog' fields `:server-fqdn', `:linger-secs', and `:vars', +respectively. The latter may also be populated via keyword pairs +appearing among DIALOGS." (when (and server-name (symbolp server-name)) (push server-name dialogs) (setq server-name nil)) - (let (loaded) - (dolist (dialog (nreverse dialogs)) - (let ((reader (erc-d-u--canned-load-dialog dialog))) - (when erc-d--slow-mo - (setq reader (erc-d-u--rewrite-for-slow-mo erc-d--slow-mo reader))) - (push (cons (erc-d-u--normalize-canned-name dialog) reader) loaded))) - (setq dialogs loaded)) - (erc-d--start host service (or server-name erc-d-server-name) - :dialog-dialogs dialogs - :dialog-vars erc-d-tmpl-vars - :dialog-linger-secs erc-d-linger-secs - :dialog-server-fqdn erc-d-server-fqdn - :dialog-match-handlers (erc-d-u--unkeyword - erc-d-match-handlers))) + (let (loaded kwds defaults args) + (while dialogs + (if-let* ((dlog (pop dialogs)) + ((keywordp dlog))) + (progn (push (pop dialogs) kwds) (push dlog kwds)) + (let ((reader (erc-d-u--canned-load-dialog dlog))) + (when erc-d--slow-mo + (setq reader (erc-d-u--rewrite-for-slow-mo erc-d--slow-mo reader))) + (push (cons (erc-d-u--normalize-canned-name dlog) reader) loaded)))) + (setq kwds (erc-d-u--unkeyword kwds) + defaults `((ending . ,erc-d-line-ending) + (server-fqdn . ,erc-d-server-fqdn) + (linger-secs . ,erc-d-linger-secs) + (vars . ,(or (plist-get kwds 'tmpl-vars) erc-d-tmpl-vars)) + (dialogs . ,(nreverse loaded))) + args (list :dialog-match-handlers + (erc-d-u--unkeyword (or (plist-get kwds 'match-handlers) + erc-d-match-handlers)))) + (pcase-dolist (`(,var . ,def) defaults) + (push (or (plist-get kwds var) def) args) + (push (intern (format ":dialog-%s" var)) args)) + (apply #'erc-d--start host service (or server-name erc-d-server-name) + args))) (defun erc-d-serve () "Start serving canned dialogs from the command line. diff --git a/test/lisp/erc/resources/erc-d/resources/foreign.eld b/test/lisp/erc/resources/erc-d/resources/foreign.eld new file mode 100644 index 0000000000..64a5dca8b1 --- /dev/null +++ b/test/lisp/erc/resources/erc-d/resources/foreign.eld @@ -0,0 +1,5 @@ +;;; -*- mode: lisp-data -*- +((one 5 "ONE one") + (0 "echo ONE one")) +((two 5 "TWO two") + (0 "echo TWO two")) commit 833a1f2c53cf90e60f5ac37f634f6cc213263004 Author: Po Lu Date: Wed Jul 27 19:56:43 2022 +0800 Fix thinko in last change * src/print.c (PRINTPREPARE): Also remove `print_free_buffer'. Record unwind protect instead. (PRINTFINISH): Stop freeing the print buffer. (bug#56773) diff --git a/src/print.c b/src/print.c index 6218c76224..384a639b31 100644 --- a/src/print.c +++ b/src/print.c @@ -101,7 +101,6 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1; ptrdiff_t old_point = -1, start_point = -1; \ ptrdiff_t old_point_byte = -1, start_point_byte = -1; \ specpdl_ref specpdl_count = SPECPDL_INDEX (); \ - bool free_print_buffer = 0; \ bool multibyte \ = !NILP (BVAR (current_buffer, enable_multibyte_characters)); \ Lisp_Object original = printcharfun; \ @@ -153,7 +152,7 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1; int new_size = 1000; \ print_buffer = xmalloc (new_size); \ print_buffer_size = new_size; \ - free_print_buffer = 1; \ + record_unwind_protect_void (print_free_buffer); \ } \ print_buffer_pos = 0; \ print_buffer_pos_byte = 0; \ @@ -180,11 +179,6 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1; print_buffer_pos_byte, 0, 1, 0); \ signal_after_change (PT - print_buffer_pos, 0, print_buffer_pos);\ } \ - if (free_print_buffer) \ - { \ - xfree (print_buffer); \ - print_buffer = 0; \ - } \ unbind_to (specpdl_count, Qnil); \ if (MARKERP (original)) \ set_marker_both (original, Qnil, PT, PT_BYTE); \ @@ -194,6 +188,16 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1; old_point_byte + (old_point_byte >= start_point_byte \ ? PT_BYTE - start_point_byte : 0)); +/* This is used to free the print buffer; we don't simply record xfree + since print_buffer can be reallocated during the printing. */ + +static void +print_free_buffer (void) +{ + xfree (print_buffer); + print_buffer = NULL; +} + /* This is used to restore the saved contents of print_buffer when there is a recursive call to print. */ commit e6b0fa4408c8e7b8bc6db70aeedbcbd235bdd7c3 Author: Michael Albinus Date: Wed Jul 27 13:46:53 2022 +0200 ; Instrument Tramp tests ; * test/infra/test-jobs.yml (test-lisp-net-inotify): Run expensive. ; * test/lisp/net/tramp-tests.el (tramp-test32-shell-command): Instrument. diff --git a/test/infra/test-jobs.yml b/test/infra/test-jobs.yml index 51707c181b..c18a3ca0d9 100644 --- a/test/infra/test-jobs.yml +++ b/test/infra/test-jobs.yml @@ -338,7 +338,7 @@ test-lisp-net-inotify: - test/lisp/net/*resources/** variables: target: emacs-inotify - make_params: "-k -C test check-lisp-net" + make_params: "-k -C test check-lisp-net SELECTOR='(not (tag :unstable))'" test-lisp-nxml-inotify: stage: normal diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 784ef93f5b..b064e3f5d0 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -5400,13 +5400,21 @@ INPUT, if non-nil, is a string sent to the process." (let ((stderr (generate-new-buffer "*stderr*"))) (unwind-protect (with-temp-buffer + (when (getenv "EMACS_EMBA_CI") + (tramp--test-message "Hallo1")) (funcall this-shell-command "echo foo >&2; echo bar" (current-buffer) stderr) + (when (getenv "EMACS_EMBA_CI") + (tramp--test-message "Hallo2")) (should (string-equal "bar\n" (buffer-string))) + (when (getenv "EMACS_EMBA_CI") + (tramp--test-message "Hallo3")) ;; Check stderr. (should - (string-equal "foo\n" (tramp-get-buffer-string stderr)))) + (string-equal "foo\n" (tramp-get-buffer-string stderr))) + (when (getenv "EMACS_EMBA_CI") + (tramp--test-message "Hallo4"))) ;; Cleanup. (ignore-errors (kill-buffer stderr)))))) commit db4dd28c21f95361de620c6e543d23da5d982fd5 Author: Michael Albinus Date: Wed Jul 27 12:51:11 2022 +0200 In Tramp, use `string-empty-p' and `string-equal-ignore-case' consequently * lisp/net/tramp.el (tramp-find-method): * lisp/net/tramp-cmds.el (tramp-change-syntax): * lisp/net/tramp-sh.el (tramp-sh-get-signal-strings) (tramp-open-connection-setup-interactive-shell): Use `string-empty-p'. * lisp/net/tramp-compat.el (tramp-compat-string-equal-ignore-case): New defalias. * lisp/net/tramp-gvfs.el (tramp-gvfs-handler-mounted-unmounted): Use it. diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index bd2dbf4a1e..5c8012e553 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -46,7 +46,7 @@ SYNTAX can be one of the symbols `default' (default), (let ((input (completing-read "Enter Tramp syntax: " (tramp-syntax-values) nil t (symbol-name tramp-syntax)))) - (unless (string-equal input "") + (unless (string-empty-p input) (list (intern input))))) (when syntax (customize-set-variable 'tramp-syntax syntax))) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index ef5b1f7ec9..bc32044451 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -312,6 +312,13 @@ CONDITION can also be a list of error conditions." (if (>= n (length list)) list (nbutlast list (- (length list) n))))))) +;; Function `string-equal-ignore-case' is new in Emacs 29.1. +(defalias 'tramp-compat-string-equal-ignore-case + (if (fboundp 'string-equal-ignore-case) + #'string-equal-ignore-case + (lambda (string1 string2) + (eq t (compare-strings string1 nil nil string2 nil nil t))))) + (dolist (elt (all-completions "tramp-compat-" obarray 'functionp)) (put (intern elt) 'tramp-suppress-trace t)) @@ -328,6 +335,6 @@ CONDITION can also be a list of error conditions." ;; parentheses with a backslash in docstrings anymore. ;; ;; * Starting with Emacs 27.1, there's `make-empty-file'. Could be -;; used instead of `write-region'. +;; used instead of `(write-region "" ...)'. ;;; tramp-compat.el ends here diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index d9afcf93c1..2f97b2cb91 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -1889,7 +1889,7 @@ Their full names are \"org.gtk.vfs.MountTracker.mounted\" and v 6 "%s %s" signal-name (tramp-gvfs-stringify-dbus-message mount-info)) (tramp-flush-file-property v "/" "list-mounts") - (if (string-equal (downcase signal-name) "unmounted") + (if (tramp-compat-string-equal-ignore-case signal-name "unmounted") (tramp-flush-file-properties v "/") ;; Set mountpoint and location. (tramp-set-file-property v "/" "fuse-mountpoint" fuse-mountpoint) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index b991de954c..172933859c 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -3115,7 +3115,7 @@ implementation will be used." (with-current-buffer (tramp-get-connection-buffer vec) (goto-char (point-min)) (buffer-substring (point-at-bol) (point-at-eol))))) - (if (string-equal res "") + (if (string-empty-p res) (format "Signal %d" i) res))) result)) @@ -4434,7 +4434,7 @@ process to set up. VEC specifies the connection." (copy-sequence tramp-remote-process-environment)))) (setq item (split-string item "=" 'omit)) (setcdr item (string-join (cdr item) "=")) - (if (and (stringp (cdr item)) (not (string-equal (cdr item) ""))) + (if (and (stringp (cdr item)) (not (string-empty-p (cdr item)))) (push (format "%s %s" (car item) (cdr item)) vars) (push (car item) unset))) (when vars diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 3f78c8d658..c123b2eac1 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1558,7 +1558,7 @@ of `process-file', `start-file-process', or `shell-command'." This is METHOD, if non-nil. Otherwise, do a lookup in `tramp-default-method-alist' and `tramp-default-method'." (when (and method - (or (string-equal method "") + (or (string-empty-p method) (string-equal method tramp-default-method-marker))) (setq method nil)) (let ((result commit 186429888981fb818624847f7356908f253b1bda Author: Lars Ingebrigtsen Date: Wed Jul 27 12:01:54 2022 +0200 Update test-print-unreadable-function after fix * test/lisp/subr-tests.el (test-print-unreadable-function): Update test after fix. diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index d45f409e85..20f81d1ddc 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -1037,7 +1037,6 @@ final or penultimate step during initialization.")) (should-not (readablep (make-marker)))) (ert-deftest test-print-unreadable-function () - :expected-result :failed ;; Check that problem with unwinding properly is fixed (bug#56773). (with-temp-buffer (let ((buf (current-buffer))) commit f21feaf00e78087dc6bed930695f449a52541bee Author: YugaEgo Date: Wed Jul 27 11:52:01 2022 +0200 Improve 'diff-whitespace-style' user option declaration * lisp/vc/diff-mode.el (diff-whitespace-style): Use ':require'. Minor docstring fix. (top level): Do not require 'whitespace. (whitespace-style, whitespace-trailing-regexp): Add defvars (rollback recent removal). * etc/NEWS: Extend 'diff-whitespace-style' introduction. (Bug#56679) (bug#56679). diff --git a/etc/NEWS b/etc/NEWS index 7c1462ee57..b79e216aa0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1206,7 +1206,9 @@ contents. --- *** New user option 'diff-whitespace-style'. -This option determines buffer-local 'whitespace-style' value. +Sets the value of the buffer-local variable 'whitespace-style' in +'diff-mode' buffers. By default, this variable is '(face trailing)', +which preserves behavior from previous Emacs versions. ** Ispell diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 8d9caf35a3..aa426446d7 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -56,7 +56,6 @@ (eval-when-compile (require 'cl-lib)) (eval-when-compile (require 'subr-x)) (require 'easy-mmode) -(require 'whitespace) (autoload 'vc-find-revision "vc") (autoload 'vc-find-revision-no-save "vc") @@ -149,7 +148,8 @@ and hunk-based syntax highlighting otherwise as a fallback." (const :tag "Allow hunk-based fallback" hunk-also))) (defcustom diff-whitespace-style '(face trailing) - "Specify `whitespace-style' variable for the current Diff mode buffer." + "Specify `whitespace-style' variable for `diff-mode' buffers." + :require 'whitespace :type (get 'whitespace-style 'custom-type) :version "29.1") @@ -1490,6 +1490,9 @@ See `after-change-functions' for the meaning of BEG, END and LEN." (nconc minor-mode-map-alist (list (cons 'diff-mode-read-only diff-mode-shared-map)))) +(defvar whitespace-style) +(defvar whitespace-trailing-regexp) + ;;;###autoload (define-derived-mode diff-mode fundamental-mode "Diff" "Major mode for viewing/editing context diffs. commit bfa951cdfad482a106bed11e4f11cedfad58570a Author: Po Lu Date: Wed Jul 27 17:39:14 2022 +0800 Fix invalid current buffer after print-unreadable-function signals * src/print.c (PRINTPREPARE): Remove `old' and record_unwind_current_buffer instead. (PRINTFINISH): Stop restoring `old'. (bug#56773) diff --git a/src/print.c b/src/print.c index b5a621f80a..6218c76224 100644 --- a/src/print.c +++ b/src/print.c @@ -98,7 +98,6 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1; or call strout to output a block of characters. */ #define PRINTPREPARE \ - struct buffer *old = current_buffer; \ ptrdiff_t old_point = -1, start_point = -1; \ ptrdiff_t old_point_byte = -1, start_point_byte = -1; \ specpdl_ref specpdl_count = SPECPDL_INDEX (); \ @@ -106,6 +105,7 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1; bool multibyte \ = !NILP (BVAR (current_buffer, enable_multibyte_characters)); \ Lisp_Object original = printcharfun; \ + record_unwind_current_buffer (); \ if (NILP (printcharfun)) printcharfun = Qt; \ if (BUFFERP (printcharfun)) \ { \ @@ -192,8 +192,7 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1; SET_PT_BOTH (old_point + (old_point >= start_point \ ? PT - start_point : 0), \ old_point_byte + (old_point_byte >= start_point_byte \ - ? PT_BYTE - start_point_byte : 0)); \ - set_buffer_internal (old); + ? PT_BYTE - start_point_byte : 0)); /* This is used to restore the saved contents of print_buffer when there is a recursive call to print. */ commit 8be5481b8ed869e1ac04c07c3919a9a49afd8667 Author: Lars Ingebrigtsen Date: Wed Jul 27 11:38:19 2022 +0200 Add a test for python-mode comment/else problem Based on a patch from kobarity diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 3b10bde23b..6f2ad87f81 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -1122,6 +1122,35 @@ if save: (python-indent-line t) (should (= (python-indent-calculate-indentation t) 8)))) +(ert-deftest python-indent-dedenters-comment-else () + "Test de-indentation for the else keyword with comments before it." + (python-tests-with-temp-buffer + " +if save: + try: + write_to_disk(data) + except IOError: + msg = 'Error saving to disk' + message(msg) + logger.exception(msg) + except Exception: + if hide_details: + logger.exception('Unhandled exception') + # comment + else + finally: + data.free() +" + (python-tests-look-at "else\n") + (should (eq (car (python-indent-context)) :at-dedenter-block-start)) + (should (= (python-indent-calculate-indentation) 8)) + (python-indent-line t) + (should (= (python-indent-calculate-indentation t) 4)) + (python-indent-line t) + (should (= (python-indent-calculate-indentation t) 0)) + (python-indent-line t) + (should (= (python-indent-calculate-indentation t) 8)))) + (ert-deftest python-indent-dedenters-3 () "Test de-indentation for the except keyword." (python-tests-with-temp-buffer commit dc84264f3cb2ea9ab5b0af9f3529ebddb6bc0219 Author: Stephen Berman Date: Wed Jul 27 11:37:31 2022 +0200 Fix comment/else indentation problem in python-mode * lisp/progmodes/python.el (python-info-dedenter-opening-block-positions): Fix indentation of "else" after a comment (bug#56742). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index ec7d657220..b8fc7d4c54 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -5171,7 +5171,8 @@ likely an invalid python file." (while (and (< (point) cur-line) (setq no-back-indent (or (> (current-indentation) indentation) - (python-info-current-line-empty-p)))) + (python-info-current-line-empty-p) + (python-info-current-line-comment-p)))) (forward-line))) no-back-indent))) (setq collected-indentations commit 27b5ab80ec2785ed0e178f695ec3a5f5fabdbea2 Author: Po Lu Date: Wed Jul 27 16:00:29 2022 +0800 Fix frame determination for XI touch events * src/xterm.c (handle_one_xevent): Find touchscreen event windows using x_window_to_frame. diff --git a/src/xterm.c b/src/xterm.c index 48e9a174fa..2067e8bb74 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -21826,7 +21826,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, if (xi_find_touch_point (device, xev->detail)) emacs_abort (); - f = x_any_window_to_frame (dpyinfo, xev->event); + f = x_window_to_frame (dpyinfo, xev->event); #ifdef HAVE_GTK3 menu_bar_p = (f && FRAME_X_OUTPUT (f)->menubar_widget @@ -21924,7 +21924,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, touchpoint->x = xev->event_x; touchpoint->y = xev->event_y; - f = x_any_window_to_frame (dpyinfo, xev->event); + f = x_window_to_frame (dpyinfo, xev->event); if (f && device->direct_p) { @@ -21967,7 +21967,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, if (unlinked_p) { - f = x_any_window_to_frame (dpyinfo, xev->event); + f = x_window_to_frame (dpyinfo, xev->event); if (f && device->direct_p) {