commit 44541c78541a96f85f3316a527374c4e4d3c75fc (HEAD, refs/remotes/origin/master) Author: Stefan Kangas Date: Mon Oct 17 08:01:51 2022 +0200 Make `message-canlock-generate' faster * lisp/gnus/message.el (message-canlock-generate): Improve performance by several orders of magnitude. diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 5e4e9854a6..a714e31876 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -5192,10 +5192,7 @@ command evaluates `message-send-mail-hook' just before sending a message." (defun message-canlock-generate () "Return a string that is non-trivial to guess. Do not use this for anything important, it is cryptographically weak." - (sha1 (concat (message-unique-id) - (format "%x%x%x" (random) (random) (random)) - (prin1-to-string (recent-keys)) - (prin1-to-string (garbage-collect))))) + (secure-hash 'sha1 'iv-auto 128)) (defvar canlock-password) (defvar canlock-password-for-verify) commit 4a6ad6e18f4de30e30f2a5c87c08078eaec821b5 Author: Dmitry Gutov Date: Mon Oct 17 02:46:02 2022 +0300 Add default implementation for 'checkin-patch' * lisp/vc/vc.el (vc-default-checkin-patch): Add default implementation for 'checkin-patch' (bug#52349). The first attempt was here: https://lists.gnu.org/archive/html/emacs-devel/2022-08/msg01464.html diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 8d0680888a..7152b51eff 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1683,6 +1683,50 @@ Runs the normal hooks `vc-before-checkin-hook' and `vc-checkin-hook'." backend patch-string)) +(defun vc-default-checkin-patch (_backend patch-string comment) + (pcase-let* ((`(,backend ,files) (with-temp-buffer + (insert patch-string) + (diff-vc-deduce-fileset))) + (tmpdir (make-temp-file "vc-checkin-patch" t))) + (dolist (f files) + (make-directory (file-name-directory (expand-file-name f tmpdir)) t) + (copy-file (expand-file-name f) + (expand-file-name f tmpdir))) + (unwind-protect + (progn + (dolist (f files) + (with-current-buffer (find-file-noselect f) + (vc-revert-file f))) + (with-temp-buffer + ;; Trying to support CVS too. Assuming that vc-diff + ;; there will usually the diff root in default-directory. + (when (vc-find-backend-function backend 'root) + (setq-local default-directory + (vc-call-backend backend 'root (car files)))) + (unless (eq 0 + (call-process-region patch-string + nil + "patch" + nil + t + nil + "-p1" + "-r" null-device + "--no-backup-if-mismatch" + "-i" "-")) + (user-error "Patch failed: %s" (buffer-string)))) + (dolist (f files) + (with-current-buffer (get-file-buffer f) + (revert-buffer t t t))) + (vc-call-backend backend 'checkin files comment)) + (dolist (f files) + (copy-file (expand-file-name f tmpdir) + (expand-file-name f) + t) + (with-current-buffer (get-file-buffer f) + (revert-buffer t t t)) + (delete-directory tmpdir t))))) + ;;; Additional entry points for examining version histories ;; (defun vc-default-diff-tree (backend dir rev1 rev2) commit 13d6e8fa54843b0b087e5a9c266e4b7e0d709c3f Author: Stefan Monnier Date: Sun Oct 16 12:01:47 2022 -0400 cl-generic: Fix `advertised-calling-convention` declarations * lisp/emacs-lisp/cl-generic.el (cl-generic-define-method): Preserve the `advertised-calling-convention`, if any (bug#58563). * lisp/subr.el (declare): Warn when we hit this. * lisp/emacs-lisp/byte-run.el (get-advertised-calling-convention): New fun. * lisp/progmodes/elisp-mode.el (elisp-get-fnsym-args-string): * lisp/help-fns.el (help-fns--signature): * lisp/emacs-lisp/bytecomp.el (byte-compile-fdefinition): Use it. * test/lisp/emacs-lisp/cl-generic-tests.el (cl-generic-tests--acc): New fun. (cl-generic-tests--advertised-calling-convention-bug58563): New test. diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 9db84c31b8..a33808ab92 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -481,6 +481,11 @@ convention was modified." (puthash (indirect-function function) signature advertised-signature-table)) +(defun get-advertised-calling-convention (function) + "Get the advertised SIGNATURE of FUNCTION. +Return t if there isn't any." + (gethash function advertised-signature-table t)) + (defun make-obsolete (obsolete-name current-name when) "Make the byte-compiler warn that function OBSOLETE-NAME is obsolete. OBSOLETE-NAME should be a function name or macro name (a symbol). diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 74ba8984f2..3ceb5da804 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1405,11 +1405,11 @@ when printing the error message." (and (not macro-p) (compiled-function-p (symbol-function fn))))) (setq fn (symbol-function fn))) - (let ((advertised (gethash (if (and (symbolp fn) (fboundp fn)) - ;; Could be a subr. - (symbol-function fn) - fn) - advertised-signature-table t))) + (let ((advertised (get-advertised-calling-convention + (if (and (symbolp fn) (fboundp fn)) + ;; Could be a subr. + (symbol-function fn) + fn)))) (cond ((listp advertised) (if macro-p diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index b3ade3b894..7b6d43e572 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -650,13 +650,17 @@ The set of acceptable TYPEs (also called \"specializers\") is defined (cl--generic-name generic) qualifiers specializers)) current-load-list :test #'equal) - (let (;; Prevent `defalias' from recording this as the definition site of + (let ((old-adv-cc (get-advertised-calling-convention + (symbol-function sym))) + ;; Prevent `defalias' from recording this as the definition site of ;; the generic function. current-load-list ;; BEWARE! Don't purify this function definition, since that leads ;; to memory corruption if the hash-tables it holds are modified ;; (the GC doesn't trace those pointers). (purify-flag nil)) + (when (listp old-adv-cc) + (set-advertised-calling-convention gfun old-adv-cc nil)) ;; But do use `defalias', so that it interacts properly with nadvice, ;; e.g. for tracing/debug-on-entry. (defalias sym gfun))))) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index eef895ae88..e29f763dab 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -669,7 +669,7 @@ the C sources, too." "Insert usage at point and return docstring. With highlighting." (if (keymapp function) doc ; If definition is a keymap, skip arglist note. - (let* ((advertised (gethash real-def advertised-signature-table t)) + (let* ((advertised (get-advertised-calling-convention real-def)) (arglist (if (listp advertised) advertised (help-function-arglist real-def))) (usage (help-split-fundoc doc function))) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 7e7ea6aeb9..537b9484bd 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -1826,8 +1826,8 @@ or elsewhere, return a 1-line docstring." (eq 'function (aref elisp--eldoc-last-data 2))) (aref elisp--eldoc-last-data 1)) (t - (let* ((advertised (gethash (indirect-function sym) - advertised-signature-table t)) + (let* ((advertised (get-advertised-calling-convention + (indirect-function sym))) doc (args (cond diff --git a/lisp/subr.el b/lisp/subr.el index 56ce9fa69b..08dfe7aa43 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -344,7 +344,7 @@ in compilation warnings about unused variables. ;; FIXME: This let often leads to "unused var" warnings. `((let ((,var ,counter)) ,@(cddr spec))))))) -(defmacro declare (&rest _specs) +(defmacro declare (&rest specs) "Do not evaluate any arguments, and return nil. If a `declare' form appears as the first form in the body of a `defun' or `defmacro' form, SPECS specifies various additional @@ -355,8 +355,16 @@ The possible values of SPECS are specified by `defun-declarations-alist' and `macro-declarations-alist'. For more information, see info node `(elisp)Declare Form'." - ;; FIXME: edebug spec should pay attention to defun-declarations-alist. - nil) + ;; `declare' is handled directly by `defun/defmacro' rather than here. + ;; If we get here, it's because there's a `declare' somewhere not attached + ;; to a `defun/defmacro', i.e. a `declare' which doesn't do what it's + ;; intended to do. + (let ((form `(declare . ,specs))) ;; FIXME: WIBNI we had &whole? + (macroexp-warn-and-return + (format-message "Stray `declare' form: %S" form) + ;; Make a "unique" harmless form to circumvent + ;; the cache in `macroexp-warn-and-return'. + `(progn ',form nil) nil 'compile-only))) (defmacro ignore-errors (&rest body) "Execute BODY; if an error occurs, return nil. diff --git a/test/lisp/emacs-lisp/cl-generic-tests.el b/test/lisp/emacs-lisp/cl-generic-tests.el index 56b766769e..8e807b1591 100644 --- a/test/lisp/emacs-lisp/cl-generic-tests.el +++ b/test/lisp/emacs-lisp/cl-generic-tests.el @@ -297,5 +297,27 @@ Edebug symbols (Bug#42672)." (intern "cl-defgeneric/edebug/method/2 (number)") 'cl-defgeneric/edebug/method/2)))))) +(cl-defgeneric cl-generic-tests--acc (x &optional y) + (declare (advertised-calling-convention (x) "671.2"))) + +(cl-defmethod cl-generic-tests--acc ((x float)) (+ x 5.0)) + +(ert-deftest cl-generic-tests--advertised-calling-convention-bug58563 () + (should (equal (get-advertised-calling-convention + (indirect-function 'cl-generic-tests--acc)) + '(x))) + (should + (condition-case err + (let ((lexical-binding t) + (byte-compile-debug t) + (byte-compile-error-on-warn t)) + (byte-compile '(cl-defmethod cl-generic-tests--acc ((x list)) + (declare (advertised-calling-convention (y) "1.1")) + (cons x '(5 5 5 5 5)))) + nil) + (error + (and (eq 'error (car err)) + (string-match "Stray.*declare" (cadr err))))))) + (provide 'cl-generic-tests) ;;; cl-generic-tests.el ends here commit 0e5fc2345d8ec72fd8f7ad51ce1e42040e0e91da Author: kobarity Date: Sun Oct 16 15:26:29 2022 +0200 Move and rename Python completion ERTs * test/lisp/progmodes/python-tests.el (python-shell-completion-at-point-1) (python-shell-completion-at-point-native-1) (python-completion-at-point-1) (python-completion-at-point-2, python-completion-at-point-pdb-1) (python-completion-at-point-native-1) (python-completion-at-point-native-2) (python-completion-at-point-native-with-ffap-1) (python-completion-at-point-native-with-eldoc-1): Renamed tests (bug#58565). diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 71bd0e0d68..81c9217c62 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -4396,7 +4396,41 @@ def foo(): (python-shell-interpreter "/some/path/to/bin/pypy")) (should (python-shell-completion-native-interpreter-disabled-p)))) -(ert-deftest python-shell-completion-1 () +(ert-deftest python-shell-completion-at-point-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + "" + (python-shell-with-shell-buffer + (insert "import abc") + (comint-send-input) + (python-tests-shell-wait-for-prompt) + (insert "abc.") + (should (nth 2 (python-shell-completion-at-point))) + (end-of-line 0) + (should-not (nth 2 (python-shell-completion-at-point)))))) + +(ert-deftest python-shell-completion-at-point-native-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + "" + (python-shell-completion-native-turn-on) + (python-shell-with-shell-buffer + (insert "import abc") + (comint-send-input) + (python-tests-shell-wait-for-prompt) + (insert "abc.") + (should (nth 2 (python-shell-completion-at-point))) + (end-of-line 0) + (should-not (nth 2 (python-shell-completion-at-point)))))) + + + +;;; PDB Track integration + + +;;; Symbol completion + +(ert-deftest python-completion-at-point-1 () (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-buffer-with-shell " @@ -4411,7 +4445,7 @@ import abc (insert "A") (should (completion-at-point))))) -(ert-deftest python-shell-completion-2 () +(ert-deftest python-completion-at-point-2 () "Should work regardless of the point in the Shell buffer." (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-buffer-with-shell @@ -4427,7 +4461,7 @@ import abc (insert "abc.") (should (completion-at-point))))) -(ert-deftest python-shell-completion-pdb-1 () +(ert-deftest python-completion-at-point-pdb-1 () "Should not complete PDB commands in Python buffer." (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-buffer-with-shell @@ -4444,7 +4478,7 @@ print('Hello') (insert "u") (should-not (nth 2 (python-completion-at-point)))))) -(ert-deftest python-shell-completion-native-1 () +(ert-deftest python-completion-at-point-native-1 () (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-buffer-with-shell " @@ -4460,7 +4494,7 @@ import abc (insert "A") (should (completion-at-point))))) -(ert-deftest python-shell-completion-native-2 () +(ert-deftest python-completion-at-point-native-2 () "Should work regardless of the point in the Shell buffer." (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-buffer-with-shell @@ -4477,7 +4511,7 @@ import abc (insert "abc.") (should (completion-at-point))))) -(ert-deftest python-shell-completion-native-with-ffap-1 () +(ert-deftest python-completion-at-point-native-with-ffap-1 () (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-buffer-with-shell " @@ -4493,7 +4527,7 @@ import abc (python-ffap-module-path "abc.") (should (completion-at-point))))) -(ert-deftest python-shell-completion-native-with-eldoc-1 () +(ert-deftest python-completion-at-point-native-with-eldoc-1 () (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-buffer-with-shell " @@ -4509,40 +4543,6 @@ import abc (python-eldoc-function) (should (completion-at-point))))) -(ert-deftest python-shell-completion-shell-buffer-1 () - (skip-unless (executable-find python-tests-shell-interpreter)) - (python-tests-with-temp-buffer-with-shell - "" - (python-shell-with-shell-buffer - (insert "import abc") - (comint-send-input) - (python-tests-shell-wait-for-prompt) - (insert "abc.") - (should (nth 2 (python-shell-completion-at-point))) - (end-of-line 0) - (should-not (nth 2 (python-shell-completion-at-point)))))) - -(ert-deftest python-shell-completion-shell-buffer-native-1 () - (skip-unless (executable-find python-tests-shell-interpreter)) - (python-tests-with-temp-buffer-with-shell - "" - (python-shell-completion-native-turn-on) - (python-shell-with-shell-buffer - (insert "import abc") - (comint-send-input) - (python-tests-shell-wait-for-prompt) - (insert "abc.") - (should (nth 2 (python-shell-completion-at-point))) - (end-of-line 0) - (should-not (nth 2 (python-shell-completion-at-point)))))) - - - -;;; PDB Track integration - - -;;; Symbol completion - ;;; Fill paragraph commit 494ccec94ede12a56c9fb2393a3c75260b8638a7 Author: Stefan Kangas Date: Sun Oct 16 13:53:37 2022 +0200 Prefer defvar-keymap in ansi-osc.el * lisp/ansi-osc.el (ansi-osc-hyperlink-map): Prefer defvar-keymap. diff --git a/lisp/ansi-osc.el b/lisp/ansi-osc.el index 34154998cd..499c9dce73 100644 --- a/lisp/ansi-osc.el +++ b/lisp/ansi-osc.el @@ -125,13 +125,11 @@ and `shell-dirtrack-mode'." ;; Hyperlink handling (OSC 8) -(defvar ansi-osc-hyperlink-map - (let ((map (make-sparse-keymap))) - (define-key map "\C-c\r" 'browse-url-button-open) - (define-key map [mouse-2] 'browse-url-button-open) - (define-key map [follow-link] 'mouse-face) - map) - "Keymap used by OSC 8 hyperlink buttons.") +(defvar-keymap ansi-osc-hyperlink-map + :doc "Keymap used by OSC 8 hyperlink buttons." + "C-c RET" #'browse-url-button-open + "" #'browse-url-button-open + "" 'mouse-face) (define-button-type 'ansi-osc-hyperlink 'keymap ansi-osc-hyperlink-map commit d4244ec8cc42672fbec5fdbbd8eb9f257d2f974c Author: Stefan Kangas Date: Sun Oct 16 13:02:24 2022 +0200 Make help-for-help echo key on failure * lisp/help-macro.el (make-help-screen): Echo key on failure. diff --git a/lisp/help-macro.el b/lisp/help-macro.el index 962bc5a8d8..cf024afe25 100644 --- a/lisp/help-macro.el +++ b/lisp/help-macro.el @@ -211,6 +211,9 @@ and then returns." (iconify-frame new-frame)) (setq new-frame nil))) (unless (equal (key-description key) "C-g") + (message (substitute-command-keys + (format "No help command is bound to `\\`%s''" + (key-description key)))) (ding)))))) (when config (set-window-configuration config)) commit 77d5be5877f7a6c2622d6d78d15bbfd89f8751f4 Author: Stefan Kangas Date: Sun Oct 16 13:01:00 2022 +0200 Bind "home"/"end" in help-for-help * lisp/help-macro.el (make-help-screen): Bind "home"/"end" keys to scrolling up/down. diff --git a/lisp/help-macro.el b/lisp/help-macro.el index 687d6fbb4e..962bc5a8d8 100644 --- a/lisp/help-macro.el +++ b/lisp/help-macro.el @@ -147,16 +147,16 @@ and then returns." (while (or (memq char (append help-event-list (cons help-char '( ?? ?\C-v ?\s ?\177 ?\M-v ?\S-\s deletechar backspace vertical-scroll-bar - next prior up down)))) + home end next prior up down)))) (eq (car-safe char) 'switch-frame) (equal key "\M-v")) (condition-case nil (cond ((eq (car-safe char) 'switch-frame) (handle-switch-frame char)) - ((memq char '(?\C-v ?\s next)) + ((memq char '(?\C-v ?\s next end)) (scroll-up)) - ((or (memq char '(?\177 ?\M-v ?\S-\s deletechar backspace prior)) + ((or (memq char '(?\177 ?\M-v ?\S-\s deletechar backspace prior home)) (equal key "\M-v")) (scroll-down)) ((memq char '(down)) commit 82257951e9794ac368c405d1ab8ec86a7c175a31 Author: Stefan Kangas Date: Sun Oct 16 12:59:13 2022 +0200 Don't ding when exiting help-for-help with C-g * lisp/help-macro.el (make-help-screen): Don't ding on "C-g". diff --git a/lisp/help-macro.el b/lisp/help-macro.el index 91c2a80400..687d6fbb4e 100644 --- a/lisp/help-macro.el +++ b/lisp/help-macro.el @@ -210,7 +210,8 @@ and then returns." (unless (eq new-frame (selected-frame)) (iconify-frame new-frame)) (setq new-frame nil))) - (ding))))) + (unless (equal (key-description key) "C-g") + (ding)))))) (when config (set-window-configuration config)) (when new-frame commit 0164d5e71ddc05108834d92d333959397d4f6f46 Author: Lars Ingebrigtsen Date: Sun Oct 16 11:52:56 2022 +0200 Clear misleading message in help-quit-or-quick * lisp/help.el (help-quit-or-quick): Clear misleading message (bug#58542). diff --git a/lisp/help.el b/lisp/help.el index 3f5e57d7d5..1cfd044db8 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -259,7 +259,10 @@ buffer.") ;; help command loop. (help-quit)) ((and-let* ((window (get-buffer-window "*Quick Help*"))) - (quit-window t window))) + (quit-window t window) + ;; Clear the message we may have gotten from `C-h' and then + ;; waiting before hitting `q'. + (message ""))) ((help-quick)))) (defvar help-return-method nil commit cb968b48cbe480364d39476e4d1c6da802e304f0 Author: Philip Kaludercic Date: Sun Oct 16 11:16:52 2022 +0200 ; * lisp/vc/vc.el (vc-prepare-patch): Fix pluralisation diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 5876cb34dd..8d0680888a 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -3371,7 +3371,8 @@ revisions, those revisions will be used." revisions))) (if vc-prepare-patches-separately (dolist (patch (reverse patches) - (message "Prepared %d patches..." (length patches))) + (message "Prepared %d patch%s..." (length patches) + (if (length> patches 1) "es" ""))) (compose-mail addressee (plist-get patch :subject) nil nil nil nil commit d8624ad51984ff8dbae57120e7616e4e91d4ab2c Author: Philip Kaludercic Date: Sun Oct 16 11:10:34 2022 +0200 ; * lisp/vc/vc.el (vc-prepare-patch): Remove 'exit-recursive-edit' diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 781e7785e4..5876cb34dd 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -3375,8 +3375,7 @@ revisions, those revisions will be used." (compose-mail addressee (plist-get patch :subject) nil nil nil nil - `((kill-buffer ,(plist-get patch :buffer)) - (exit-recursive-edit))) + `((kill-buffer ,(plist-get patch :buffer)))) (rfc822-goto-eoh) (forward-line) (save-excursion ;don't jump to the end (insert-buffer-substring commit cb975c6183ed1653cc8d7fe5283a9b294bf07bf4 Author: kobarity Date: Sun Oct 16 11:26:29 2022 +0200 Fix invalid search bound error in python-shell-completion-at-point * lisp/progmodes/python.el (python-shell-completion-at-point): Add check if point is before line-start. * test/lisp/progmodes/python-tests.el (python-shell-completion-shell-buffer-1) (python-shell-completion-shell-buffer-native-1): New tests (bug#58548). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 50f1e6752e..1119589423 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4080,15 +4080,18 @@ using that one instead of current buffer's process." (buffer-substring-no-properties line-start (point))) (buffer-substring-no-properties line-start (point)))) (start - (save-excursion - (if (not (re-search-backward - (python-rx - (or whitespace open-paren close-paren string-delimiter simple-operator)) - line-start - t 1)) - line-start - (forward-char (length (match-string-no-properties 0))) - (point)))) + (if (< (point) line-start) + (point) + (save-excursion + (if (not (re-search-backward + (python-rx + (or whitespace open-paren close-paren + string-delimiter simple-operator)) + line-start + t 1)) + line-start + (forward-char (length (match-string-no-properties 0))) + (point))))) (end (point)) (prompt-boundaries (with-current-buffer (process-buffer process) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 97dc17ce29..71bd0e0d68 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -4509,6 +4509,33 @@ import abc (python-eldoc-function) (should (completion-at-point))))) +(ert-deftest python-shell-completion-shell-buffer-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + "" + (python-shell-with-shell-buffer + (insert "import abc") + (comint-send-input) + (python-tests-shell-wait-for-prompt) + (insert "abc.") + (should (nth 2 (python-shell-completion-at-point))) + (end-of-line 0) + (should-not (nth 2 (python-shell-completion-at-point)))))) + +(ert-deftest python-shell-completion-shell-buffer-native-1 () + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + "" + (python-shell-completion-native-turn-on) + (python-shell-with-shell-buffer + (insert "import abc") + (comint-send-input) + (python-tests-shell-wait-for-prompt) + (insert "abc.") + (should (nth 2 (python-shell-completion-at-point))) + (end-of-line 0) + (should-not (nth 2 (python-shell-completion-at-point)))))) + ;;; PDB Track integration commit f9726408f6cb56b3a97a9e76be166a5156faec0b Author: Daniel Martín Date: Sun Oct 16 11:25:17 2022 +0200 Signal an error in dictionary lookup if there's no word at point * lisp/net/dictionary.el (dictionary-lookup-definition): Signal an error when there is no word at point (bug#58552). diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el index 4c52382c67..b8f5018005 100644 --- a/lisp/net/dictionary.el +++ b/lisp/net/dictionary.el @@ -1173,7 +1173,10 @@ allows editing it." (defun dictionary-lookup-definition () "Unconditionally lookup the word at point." (interactive) - (dictionary-new-search (cons (current-word) dictionary-default-dictionary))) + (let ((word (current-word))) + (unless word + (error "No word at point")) + (dictionary-new-search (cons word dictionary-default-dictionary)))) (defun dictionary-previous () "Go to the previous location in the current buffer." commit 45aabe6edae8d841a8985853394baddad4a1949e Author: kobarity Date: Sun Oct 16 11:15:22 2022 +0200 Disable completion when PDB is active in Python Shell buffer * lisp/progmodes/python.el (python-shell-completion-at-point): Disable completion in Python buffer when PDB is active in Python Shell buffer. * test/lisp/progmodes/python-tests.el (python-shell-completion-pdb-1): New test (bug#58562). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 0de76b0bde..50f1e6752e 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4102,7 +4102,10 @@ using that one instead of current buffer's process." (with-current-buffer (process-buffer process) (cond ((or (null prompt) (and is-shell-buffer - (< (point) (cdr prompt-boundaries)))) + (< (point) (cdr prompt-boundaries))) + (and (not is-shell-buffer) + (string-match-p + python-shell-prompt-pdb-regexp prompt))) #'ignore) ((or (not python-shell-completion-native-enable) ;; Even if native completion is enabled, for diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 9ad2d16930..97dc17ce29 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -4427,6 +4427,23 @@ import abc (insert "abc.") (should (completion-at-point))))) +(ert-deftest python-shell-completion-pdb-1 () + "Should not complete PDB commands in Python buffer." + (skip-unless (executable-find python-tests-shell-interpreter)) + (python-tests-with-temp-buffer-with-shell + " +import pdb + +pdb.set_trace() +print('Hello') +" + (let ((inhibit-message t)) + (python-shell-send-buffer) + (python-tests-shell-wait-for-prompt) + (goto-char (point-max)) + (insert "u") + (should-not (nth 2 (python-completion-at-point)))))) + (ert-deftest python-shell-completion-native-1 () (skip-unless (executable-find python-tests-shell-interpreter)) (python-tests-with-temp-buffer-with-shell