1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-04 02:51:31 -08:00

Merge from origin/emacs-29

d3a76db88b * lisp/repeat.el: Fix repeat-keep-prefix to allow customi...
8ef3777d54 Correct capitalization of Lisp in the manual (bug#60222)
d03ea89378 eglot.el: Add vscode-json-languageserver to eglot-server-...
8550a99378 ; * src/emacs-module.h.in (enum emacs_funcall_exit): Fix ...
fb7f3999c5 ; Fix ruby-method-params-indent's :version value
cfbfd393b4 * lisp/progmodes/project.el (project--read-file-cpd-relat...
2b1fdbffcb ruby-method-params-indent: New user option
b9e813f79f ; ruby-indent-level: Improve the docstring
399433cc2b * lisp/progmodes/project.el: Filter out empty strings fro...
23f7c9c2a9 Fix storing email into nnmail by Gnus
63cdbd986b ; Really respect browse-url var in erc-compat
64163618d2 whitespace: Fix unintended change in buffer modification ...
a75d1da911 Make emacsclient add abbreviated file names to file-name-...
b3e7768a0e Repair setopt test after error demotion to warning
This commit is contained in:
Stefan Kangas 2022-12-21 02:37:17 +01:00
commit 2bbc554db6
18 changed files with 211 additions and 102 deletions

View file

@ -930,7 +930,7 @@ used by Emacs to natively-compile any Lisp file or byte-compiled Lisp
file that is loaded into Emacs, when no natively-compiled file for it
is available. Note that because of this use of a subprocess, native
compilation may produce warning and errors which byte-compilation does
not, and lisp code may thus need to be modified to work correctly. See
not, and Lisp code may thus need to be modified to work correctly. See
@code{native-comp-async-report-warnings-errors} in @pxref{Native-Compilation
Variables} for more details.

View file

@ -71,6 +71,9 @@ switches for shortlogs, such as the one produced by 'C-x v L'.
You can now configure how to display the "*buffer-selection*" buffer
using this new option. (Or set 'display-buffer-alist' directly.)
---
*** New user option 'ruby-method-params-indent'.
** Eshell
+++

View file

@ -391,11 +391,11 @@ If START or END is negative, it counts from the end."
(cond ((fboundp 'browse-url-irc)) ; 29
((boundp 'browse-url-default-handlers) ; 28
(setf (alist-get "\\`irc6?s?://" browse-url-default-handlers
nil nil (lambda (a _)
(and (stringp a)
(string-match-p a "irc://localhost"))))
#'erc-compat--29-browse-url-irc))
(add-to-list 'browse-url-default-handlers
'("\\`irc6?s?://" . erc-compat--29-browse-url-irc)
nil (lambda (_ a)
(and (stringp (car-safe a))
(string-match-p (car a) "irc://localhost")))))
((boundp 'browse-url-browser-function) ; 27
(require 'browse-url)
(let ((existing browse-url-browser-function))

View file

@ -1765,8 +1765,7 @@ all channel buffers on all servers."
;; to, it was never realized.
;;
;; New library code should use the `erc--target' struct instead.
;; Third-party code can continue to use this until a getter for
;; `erc--target' (or whatever replaces it) is exported.
;; Third-party code can continue to use this and `erc-default-target'.
(defvar-local erc-default-recipients nil
"List of default recipients of the current buffer.")
@ -6012,13 +6011,14 @@ See also `erc-downcase'."
;; While `erc-default-target' happens to return nil in channel buffers
;; you've parted or from which you've been kicked, using it to detect
;; whether a channel is currently joined may become unreliable in the
;; future. For now, new code should consider using
;; future. For now, third-party code can use
;;
;; (erc-get-channel-user (erc-current-nick))
;;
;; and expect a nicer option eventually. For retrieving a target
;; regardless of subscription or connection status, use replacements
;; based on `erc--target' instead. See also `erc--default-target'.
;; A predicate may be provided eventually. For retrieving a target's
;; name regardless of subscription or connection status, new library
;; code should use `erc--default-target'. Third-party code should
;; continue to use `erc-default-target'.
(defun erc-default-target ()
"Return the current default target (as a character string) or nil if none."

View file

@ -776,17 +776,22 @@ article number. This function is called narrowed to an article."
(nnml--encode-headers headers)
headers))))
;; RFC2047-encode Subject and From, but leave invalid headers unencoded.
(defun nnml--encode-headers (headers)
(let ((subject (mail-header-subject headers))
(rfc2047-encoding-type 'mime))
(unless (string-match "\\`[[:ascii:]]*\\'" subject)
(setf (mail-header-subject headers)
(mail-encode-encoded-word-string subject t))))
(let ((encoded-subject
(ignore-errors (mail-encode-encoded-word-string subject t))))
(if encoded-subject
(setf (mail-header-subject headers) encoded-subject)))))
(let ((from (mail-header-from headers))
(rfc2047-encoding-type 'address-mime))
(unless (string-match "\\`[[:ascii:]]*\\'" from)
(setf (mail-header-from headers)
(rfc2047-encode-string from t)))))
(let ((encoded-from
(ignore-errors (rfc2047-encode-string from t))))
(if encoded-from
(setf (mail-header-from headers) encoded-from))))))
(defun nnml-get-nov-buffer (group &optional incrementalp)
(let ((buffer (gnus-get-buffer-create

View file

@ -190,6 +190,7 @@ chosen (interactively or automatically)."
'("pylsp" "pyls" ("pyright-langserver" "--stdio") "jedi-language-server")))
((js-json-mode json-mode json-ts-mode)
. ,(eglot-alternatives '(("vscode-json-language-server" "--stdio")
("vscode-json-languageserver" "--stdio")
("json-languageserver" "--stdio"))))
((js-mode js-ts-mode tsx-ts-mode typescript-ts-mode typescript-mode)
. ("typescript-language-server" "--stdio"))

View file

@ -1040,12 +1040,14 @@ by the user at will."
(setq substrings (cons "./" substrings))))
(new-collection (project--file-completion-table substrings))
(abbr-cpd (abbreviate-file-name common-parent-directory))
(abbr-cpd-length (length abbr-cpd))
(relname (cl-letf ((history-add-new-input nil)
((symbol-value hist)
(mapcan
(lambda (s)
(and (string-prefix-p abbr-cpd s)
(list (substring s (length abbr-cpd)))))
(not (eq abbr-cpd-length (length s)))
(list (substring s abbr-cpd-length))))
(symbol-value hist))))
(project--completing-read-strict prompt
new-collection

View file

@ -212,7 +212,7 @@ It should match the part after \"def\" and until \"=\".")
:safe 'booleanp)
(defcustom ruby-indent-level 2
"Indentation of Ruby statements."
"Number of spaces for each indentation step in `ruby-mode'."
:type 'integer
:safe 'integerp)
@ -268,6 +268,23 @@ Only has effect when `ruby-use-smie' is t."
:safe 'booleanp
:version "24.4")
(defcustom ruby-method-params-indent t
"Indentation of multiline method parameters.
When t, the parameters list is indented to the method name.
When a number, indent the parameters list this many columns
against the beginning of the method (the \"def\" keyword).
The value nil means the same as 0.
Only has effect when `ruby-use-smie' is t."
:type '(choice (const :tag "Indent to the method name" t)
(number :tag "Indent specified number of columns against def")
(const :tag "Indent to def" nil))
:safe (lambda (val) (or (memq val '(t nil)) (numberp val)))
:version "29.1")
(defcustom ruby-deep-arglist t
"Deep indent lists in parenthesis when non-nil.
Also ignores spaces after parenthesis when `space'.
@ -660,9 +677,12 @@ This only affects the output of the command `ruby-toggle-block'."
(unless (or (eolp) (forward-comment 1))
(cons 'column (current-column)))))
('(:before . " @ ")
(save-excursion
(skip-chars-forward " \t")
(cons 'column (current-column))))
(if (or (eq ruby-method-params-indent t)
(not (smie-rule-parent-p "def" "def=")))
(save-excursion
(skip-chars-forward " \t")
(cons 'column (current-column)))
(smie-rule-parent (or ruby-method-params-indent 0))))
('(:before . "do") (ruby-smie--indent-to-stmt))
('(:before . ".")
(if (smie-rule-sibling-p)

View file

@ -368,6 +368,13 @@ This property can override the value of this variable."
(defcustom repeat-keep-prefix nil
"Whether to keep the prefix arg of the previous command when repeating."
:type 'boolean
:initialize #'custom-initialize-default
:set (lambda (sym val)
(set-default sym val)
(when repeat-mode
(if repeat-keep-prefix
(add-hook 'pre-command-hook 'repeat-pre-hook)
(remove-hook 'pre-command-hook 'repeat-pre-hook))))
:group 'repeat
:version "28.1")
@ -419,7 +426,11 @@ When Repeat mode is enabled, and the command symbol has the property named
See `describe-repeat-maps' for a list of all repeatable commands."
:global t :group 'repeat
(if (not repeat-mode)
(remove-hook 'post-command-hook 'repeat-post-hook)
(progn
(remove-hook 'pre-command-hook 'repeat-pre-hook)
(remove-hook 'post-command-hook 'repeat-post-hook))
(when repeat-keep-prefix
(add-hook 'pre-command-hook 'repeat-pre-hook))
(add-hook 'post-command-hook 'repeat-post-hook)
(let* ((keymaps nil)
(commands (all-completions
@ -431,15 +442,21 @@ See `describe-repeat-maps' for a list of all repeatable commands."
(length commands)
(length (delete-dups keymaps))))))
(defvar repeat--prev-mb '(0)
"Previous minibuffer state.")
(defun repeat--command-property (property)
(or (and (symbolp this-command)
(get this-command property))
(and (symbolp real-this-command)
(get real-this-command property))))
(defun repeat-get-map ()
"Return a transient map for keys repeatable after the current command."
(when repeat-mode
(let ((rep-map (or repeat-map (repeat--command-property 'repeat-map))))
(when rep-map
(when (and (symbolp rep-map) (boundp rep-map))
(setq rep-map (symbol-value rep-map)))
rep-map))))
(defun repeat-check-key (key map)
"Check if the last key is suitable to activate the repeating MAP."
(let* ((prop (repeat--command-property 'repeat-check-key))
@ -449,50 +466,61 @@ See `describe-repeat-maps' for a list of all repeatable commands."
;; Try without modifiers:
(lookup-key map (vector (event-basic-type key))))))
(defvar repeat--prev-mb '(0)
"Previous minibuffer state.")
(defun repeat-check-map (map)
"Decides whether MAP can be used for the next command."
(and map
;; Detect changes in the minibuffer state to allow repetitions
;; in the same minibuffer, but not when the minibuffer is activated
;; in the middle of repeating sequence (bug#47566).
(or (< (minibuffer-depth) (car repeat--prev-mb))
(eq current-minibuffer-command (cdr repeat--prev-mb)))
(repeat-check-key last-command-event map)
t))
(defun repeat-pre-hook ()
"Function run before commands to handle repeatable keys."
(when (and repeat-mode repeat-keep-prefix repeat-in-progress
(not prefix-arg) current-prefix-arg)
(let ((map (repeat-get-map)))
;; Only when repeat-post-hook will activate the same map
(when (repeat-check-map map)
;; Optimize to use less logic in the function `repeat-get-map'
;; for the next call: when called again from `repeat-post-hook'
;; it will use the variable `repeat-map'.
(setq repeat-map map)
;; Preserve universal argument
(setq prefix-arg current-prefix-arg)))))
(defun repeat-post-hook ()
"Function run after commands to set transient keymap for repeatable keys."
(let ((was-in-progress repeat-in-progress))
(setq repeat-in-progress nil)
(when repeat-mode
(let ((rep-map (or repeat-map (repeat--command-property 'repeat-map))))
(when rep-map
(when (and (symbolp rep-map) (boundp rep-map))
(setq rep-map (symbol-value rep-map)))
(let ((map (copy-keymap rep-map)))
(let ((map (repeat-get-map)))
(when (repeat-check-map map)
;; Messaging
(funcall repeat-echo-function map)
(when (and
;; Detect changes in the minibuffer state to allow repetitions
;; in the same minibuffer, but not when the minibuffer is activated
;; in the middle of repeating sequence (bug#47566).
(or (< (minibuffer-depth) (car repeat--prev-mb))
(eq current-minibuffer-command (cdr repeat--prev-mb)))
(or (not repeat-keep-prefix) prefix-arg)
(repeat-check-key last-command-event map))
;; Adding an exit key
(when repeat-exit-key
(setq map (copy-keymap map))
(define-key map (if (key-valid-p repeat-exit-key)
(kbd repeat-exit-key)
repeat-exit-key)
'ignore))
;; Messaging
(unless prefix-arg
(funcall repeat-echo-function map))
(setq repeat-in-progress t)
(repeat--exit)
(let ((exitfun (set-transient-map map)))
(setq repeat-exit-function exitfun)
;; Adding an exit key
(when repeat-exit-key
(define-key map (if (key-valid-p repeat-exit-key)
(kbd repeat-exit-key)
repeat-exit-key)
'ignore))
(when (and repeat-keep-prefix (not prefix-arg))
(setq prefix-arg current-prefix-arg))
(setq repeat-in-progress t)
(let ((exitfun (set-transient-map map)))
(repeat--exit)
(setq repeat-exit-function exitfun)
(let* ((prop (repeat--command-property 'repeat-exit-timeout))
(timeout (unless (eq prop 'no) (or prop repeat-exit-timeout))))
(when timeout
(setq repeat-exit-timer
(run-with-idle-timer timeout nil #'repeat-exit))))))))))
(let* ((prop (repeat--command-property 'repeat-exit-timeout))
(timeout (unless (eq prop 'no) (or prop repeat-exit-timeout))))
(when timeout
(setq repeat-exit-timer
(run-with-idle-timer timeout nil #'repeat-exit)))))))
(setq repeat-map nil)
(setq repeat--prev-mb (cons (minibuffer-depth) current-minibuffer-command))
@ -582,6 +610,7 @@ Used in `repeat-mode'."
(push s (alist-get (get s 'repeat-map) keymaps)))))
(with-help-window (help-buffer)
(with-current-buffer standard-output
(setq-local outline-regexp "[*]+")
(insert "A list of keymaps used by commands with the symbol property `repeat-map'.\n")
(dolist (keymap (sort keymaps (lambda (a b)

View file

@ -1502,7 +1502,7 @@ so don't mark these buffers specially, just visit them normally."
minibuffer-auto-raise))
(filen (car file))
(obuf (get-file-buffer filen)))
(add-to-history 'file-name-history filen)
(file-name-history--add filen)
(if (null obuf)
(progn
(run-hooks 'pre-command-hook)

View file

@ -2268,10 +2268,11 @@ Highlighting those lines can be distracting.)"
(save-excursion (goto-char whitespace-point)
(line-beginning-position)))))
(when (= p 1)
;; See the comment in `whitespace--update-bob-eob' for why this
;; text property is added here.
(put-text-property 1 whitespace-bob-marker
'font-lock-multiline t))
(with-silent-modifications
;; See the comment in `whitespace--update-bob-eob' for why
;; this text property is added here.
(put-text-property 1 whitespace-bob-marker
'font-lock-multiline t)))
(when (< p e)
(set-match-data (list p e))
(goto-char e))))
@ -2292,10 +2293,11 @@ about to start typing, and if they do, that line and previous
empty lines will no longer be EoB empty lines. Highlighting
those lines can be distracting.)"
(when (= limit (1+ (buffer-size)))
;; See the comment in `whitespace--update-bob-eob' for why this
;; text property is added here.
(put-text-property whitespace-eob-marker limit
'font-lock-multiline t))
(with-silent-modifications
;; See the comment in `whitespace--update-bob-eob' for why this
;; text property is added here.
(put-text-property whitespace-eob-marker limit
'font-lock-multiline t)))
(let ((b (max (point) whitespace-eob-marker
whitespace-bob-marker ; See comment in the bob func.
(save-excursion (goto-char whitespace-point)
@ -2437,8 +2439,9 @@ purposes)."
(save-match-data
(when (looking-at whitespace-empty-at-bob-regexp)
(set-marker whitespace-bob-marker (match-end 1))
(put-text-property (match-beginning 1) (match-end 1)
'font-lock-multiline t))))
(with-silent-modifications
(put-text-property (match-beginning 1) (match-end 1)
'font-lock-multiline t)))))
(when (or (null end)
(>= end (save-excursion
(goto-char whitespace-eob-marker)
@ -2451,8 +2454,9 @@ purposes)."
(when (whitespace--looking-back
whitespace-empty-at-eob-regexp)
(set-marker whitespace-eob-marker (match-beginning 1))
(put-text-property (match-beginning 1) (match-end 1)
'font-lock-multiline t)))))))))
(with-silent-modifications
(put-text-property (match-beginning 1) (match-end 1)
'font-lock-multiline t))))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -116,7 +116,7 @@ enum emacs_funcall_exit
/* Function has signaled an error using `signal'. */
emacs_funcall_exit_signal = 1,
/* Function has exit using `throw'. */
/* Function has exited using `throw'. */
emacs_funcall_exit_throw = 2
};

View file

@ -83,7 +83,14 @@
(ert-deftest test-setopt ()
(should (= (setopt cus-edit-test-foo1 1) 1))
(should (= cus-edit-test-foo1 1))
(should-error (setopt cus-edit-test-foo1 :foo)))
(let* ((text-quoting-style 'grave)
(warn-txt
(with-current-buffer (get-buffer-create "*Warnings*")
(let ((inhibit-read-only t))
(erase-buffer))
(setopt cus-edit-test-foo1 :foo)
(buffer-substring-no-properties (point-min) (point-max)))))
(should (string-search "Value `:foo' does not match type number"
warn-txt))))
(provide 'cus-edit-tests)
;;; cus-edit-tests.el ends here

View file

@ -0,0 +1,18 @@
class C
def self.foo(
baz,
bar
) =
what
def foo=(
baz,
bar
)
hello
end
end
# Local Variables:
# ruby-method-params-indent: 0
# End:

View file

@ -538,3 +538,7 @@ class Bar
baz
end
end
# Local Variables:
# ruby-method-params-indent: t
# End:

View file

@ -943,16 +943,20 @@ VALUES-PLIST is a list with alternating index and value elements."
"Blub#bye"
"Blub#hiding")))))
(ert-deftest ruby--indent/converted-from-manual-test ()
:tags '(:expensive-test)
;; Converted from manual test.
(let ((buf (find-file-noselect (ert-resource-file "ruby.rb"))))
(unwind-protect
(with-current-buffer buf
(let ((orig (buffer-string)))
(indent-region (point-min) (point-max))
(should (equal (buffer-string) orig))))
(kill-buffer buf))))
(defmacro ruby-deftest-indent (file)
`(ert-deftest ,(intern (format "ruby-indent-test/%s" file)) ()
;; :tags '(:expensive-test)
(let ((buf (find-file-noselect (ert-resource-file ,file))))
(unwind-protect
(with-current-buffer buf
(let ((orig (buffer-string)))
;; Indent and check that we get the original text.
(indent-region (point-min) (point-max))
(should (equal (buffer-string) orig))))
(kill-buffer buf)))))
(ruby-deftest-indent "ruby.rb")
(ruby-deftest-indent "ruby-method-params-indent.rb")
(ert-deftest ruby--test-chained-indentation ()
(with-temp-buffer

View file

@ -76,27 +76,27 @@
"C-x w a b a c"
'((1 a) (1 b) (1 a)) "c")
(repeat-tests--check
"M-C-a b a c"
"C-M-a b a c"
'((1 a) (1 b) (1 a)) "c")
(repeat-tests--check
"M-C-z b a c"
"C-M-z b a c"
'((1 a)) "bac")
(unwind-protect
(progn
(put 'repeat-tests-call-a 'repeat-check-key 'no)
(repeat-tests--check
"M-C-z b a c"
"C-M-z b a c"
'((1 a) (1 b) (1 a)) "c"))
(put 'repeat-tests-call-a 'repeat-check-key nil)))
(let ((repeat-check-key nil))
(repeat-tests--check
"M-C-z b a c"
"C-M-z b a c"
'((1 a) (1 b) (1 a)) "c")
(unwind-protect
(progn
(put 'repeat-tests-call-a 'repeat-check-key t)
(repeat-tests--check
"M-C-z b a c"
"C-M-z b a c"
'((1 a)) "bac"))
(put 'repeat-tests-call-a 'repeat-check-key nil))))))
@ -125,15 +125,17 @@
(repeat-tests--check
"C-2 C-x w a C-3 c"
'((2 a)) "ccc"))
;; TODO: fix and uncomment
;; (let ((repeat-keep-prefix t))
;; (repeat-tests--check
;; "C-2 C-x w a b a b c"
;; '((2 a) (2 b) (2 a) (2 b)) "c")
;; (repeat-tests--check
;; "C-2 C-x w a C-1 C-2 b a C-3 C-4 b c"
;; '((2 a) (12 b) (12 a) (34 b)) "c"))
)))
;; Fixed in bug#51281 and bug#55986
(let ((repeat-keep-prefix t))
;; Re-enable to take effect.
(repeat-mode -1) (repeat-mode +1)
(repeat-tests--check
"C-2 C-x w a b a b c"
'((2 a) (2 b) (2 a) (2 b)) "c")
;; (repeat-tests--check
;; "C-2 C-x w a C-1 C-2 b a C-3 C-4 b c"
;; '((2 a) (12 b) (12 a) (34 b)) "c")
))))
;; TODO: :tags '(:expensive-test) for repeat-exit-timeout

View file

@ -327,6 +327,16 @@ buffer's content."
"«:whitespace-empty:\n"
"»")))))
(ert-deftest whitespace-tests--empty-bob-eob-modified ()
"Regression test for Bug#60066."
(whitespace-tests--with-test-buffer '()
(insert "\nx\n\n")
(goto-char 2)
(set-buffer-modified-p nil)
(let ((whitespace-style '(face empty)))
(whitespace-mode 1)
(should (not (buffer-modified-p))))))
(provide 'whitespace-tests)
;;; whitespace-tests.el ends here