1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Merge remote-tracking branch 'origin/master' into feature/android

This commit is contained in:
Po Lu 2023-05-02 08:09:17 +08:00
commit 86b7ed619c
11 changed files with 106 additions and 78 deletions

View file

@ -42,4 +42,4 @@ else
fi fi
git rev-parse HEAD | $awk -v reason=post-commit \ git rev-parse HEAD | $awk -v reason=post-commit \
-f .git/hooks/commit-msg-files.awk -f ${GIT_DIR:-.git}/hooks/commit-msg-files.awk

View file

@ -83,4 +83,4 @@ $awk -v origin_name="$1" '
# Print every SHA after oldref, up to (and including) newref. # Print every SHA after oldref, up to (and including) newref.
system("git rev-list --first-parent --reverse " oldref ".." newref) system("git rev-list --first-parent --reverse " oldref ".." newref)
} }
' | $awk -v reason=pre-push -f .git/hooks/commit-msg-files.awk ' | $awk -v reason=pre-push -f ${GIT_DIR:-.git}/hooks/commit-msg-files.awk

View file

@ -2631,6 +2631,12 @@ so the byte compiler can ignore calls whose value is ignored. This is
the same as the @code{side-effect-free} property of the function's the same as the @code{side-effect-free} property of the function's
symbol, @pxref{Standard Properties}. symbol, @pxref{Standard Properties}.
@item (important-return-value @var{val})
If @var{val} is non-@code{nil}, the byte compiler will warn about
calls to this function that do not use the returned value. This is the
same as the @code{important-return-value} property of the function's
symbol, @pxref{Standard Properties}.
@item (speed @var{n}) @item (speed @var{n})
Specify the value of @code{native-comp-speed} in effect for native Specify the value of @code{native-comp-speed} in effect for native
compilation of this function (@pxref{Native-Compilation Variables}). compilation of this function (@pxref{Native-Compilation Variables}).

View file

@ -643,6 +643,12 @@ ignore a call whose value is unused. If the property's value is
calls. In addition to byte compiler optimizations, this property is calls. In addition to byte compiler optimizations, this property is
also used for determining function safety (@pxref{Function Safety}). also used for determining function safety (@pxref{Function Safety}).
@item important-return-value
@cindex @code{important-return-value} property
A non-@code{nil} value makes the byte compiler warn about code that
calls the named function without using its returned value. This is
useful for functions where doing so is likely to be a mistake.
@item undo-inhibit-region @item undo-inhibit-region
If non-@code{nil}, the named function prevents the @code{undo} operation If non-@code{nil}, the named function prevents the @code{undo} operation
from being restricted to the active region, if @code{undo} is invoked from being restricted to the active region, if @code{undo} is invoked

View file

@ -544,17 +544,26 @@ the warning name 'suspicious'.
--- ---
*** Warn about more ignored function return values. *** Warn about more ignored function return values.
The compiler now warns when the return value from certain functions is The compiler now warns when the return value from certain functions is
ignored. Example: implicitly ignored. Example:
(progn (nreverse my-list) my-list) (progn (nreverse my-list) my-list)
will elicit a warning because it is usually pointless to call will elicit a warning because it is usually pointless to call
'nreverse' on a list without using the returned value. To silence the 'nreverse' on a list without using the returned value.
warning, make use of the value in some way, such as assigning it to a
variable. You can also wrap the function call in '(ignore ...)'.
This warning can be suppressed using 'with-suppressed-warnings' with To silence the warning, make use of the value in some way, such as
the warning name 'ignored-return-value'. assigning it to a variable. You can also wrap the function call in
'(ignore ...)', or use 'with-suppressed-warnings' with the warning
name 'ignored-return-value'.
The warning will only be issued for calls to functions declared
'important-return-value' or 'side-effect-free' (but not 'error-free').
+++
** New function declaration and property 'important-return-value'.
The declaration '(important-return-value t)' sets the
'important-return-value' property which indicates that the function
return value should probably not be thrown away implicitly.
+++ +++
** New function 'file-user-uid'. ** New function 'file-user-uid'.

View file

@ -145,6 +145,11 @@ So far, FUNCTION can only be a symbol, not a lambda expression."
(list 'function-put (list 'quote f) (list 'function-put (list 'quote f)
''side-effect-free (list 'quote val)))) ''side-effect-free (list 'quote val))))
(defalias 'byte-run--set-important-return-value
#'(lambda (f _args val)
(list 'function-put (list 'quote f)
''important-return-value (list 'quote val))))
(put 'compiler-macro 'edebug-declaration-spec (put 'compiler-macro 'edebug-declaration-spec
'(&or symbolp ("lambda" &define lambda-list lambda-doc def-body))) '(&or symbolp ("lambda" &define lambda-list lambda-doc def-body)))
@ -226,6 +231,8 @@ This may shift errors from run-time to compile-time.")
(list 'side-effect-free #'byte-run--set-side-effect-free (list 'side-effect-free #'byte-run--set-side-effect-free
"If non-nil, calls can be ignored if their value is unused. "If non-nil, calls can be ignored if their value is unused.
If `error-free', drop calls even if `byte-compile-delete-errors' is nil.") If `error-free', drop calls even if `byte-compile-delete-errors' is nil.")
(list 'important-return-value #'byte-run--set-important-return-value
"If non-nil, warn about calls not using the returned value.")
(list 'compiler-macro #'byte-run--set-compiler-macro) (list 'compiler-macro #'byte-run--set-compiler-macro)
(list 'doc-string #'byte-run--set-doc-string) (list 'doc-string #'byte-run--set-doc-string)
(list 'indent #'byte-run--set-indent) (list 'indent #'byte-run--set-indent)

View file

@ -3502,67 +3502,7 @@ lambda-expression."
;; so maybe we don't need to bother about it here? ;; so maybe we don't need to bother about it here?
(setq form (cons 'progn (cdr form))) (setq form (cons 'progn (cdr form)))
(setq handler #'byte-compile-progn)) (setq handler #'byte-compile-progn))
((and (or sef ((and (or sef (function-get (car form) 'important-return-value))
(memq (car form)
;; FIXME: Use a function property (declaration)
;; instead of this list.
'(
;; Functions that are side-effect-free
;; except for the behaviour of
;; functions passed as argument.
mapcar mapcan mapconcat
cl-mapcar cl-mapcan cl-maplist cl-map cl-mapcon
cl-reduce
assoc assoc-default plist-get plist-member
cl-assoc cl-assoc-if cl-assoc-if-not
cl-rassoc cl-rassoc-if cl-rassoc-if-not
cl-member cl-member-if cl-member-if-not
cl-adjoin
cl-mismatch cl-search
cl-find cl-find-if cl-find-if-not
cl-position cl-position-if cl-position-if-not
cl-count cl-count-if cl-count-if-not
cl-remove cl-remove-if cl-remove-if-not
cl-member cl-member-if cl-member-if-not
cl-remove-duplicates
cl-subst cl-subst-if cl-subst-if-not
cl-substitute cl-substitute-if
cl-substitute-if-not
cl-sublis
cl-union cl-intersection
cl-set-difference cl-set-exclusive-or
cl-subsetp
cl-every cl-some cl-notevery cl-notany
cl-tree-equal
;; Functions that mutate and return a list.
cl-delete-if cl-delete-if-not
;; `delete-dups' and `delete-consecutive-dups'
;; never delete the first element so it's
;; safe to ignore their return value, but
;; this isn't the case with
;; `cl-delete-duplicates'.
cl-delete-duplicates
cl-nsubst cl-nsubst-if cl-nsubst-if-not
cl-nsubstitute cl-nsubstitute-if
cl-nsubstitute-if-not
cl-nunion cl-nintersection
cl-nset-difference cl-nset-exclusive-or
cl-nreconc cl-nsublis
cl-merge
;; It's safe to ignore the value of `sort'
;; and `nreverse' when used on arrays,
;; but most calls pass lists.
nreverse
sort cl-sort cl-stable-sort
;; Adding the following functions yields many
;; positives; evaluate how many of them are
;; false first.
;;delq delete cl-delete
;;nconc plist-put
)))
;; Don't warn for arguments to `ignore'. ;; Don't warn for arguments to `ignore'.
(not (eq byte-compile--for-effect 'for-effect-no-warn)) (not (eq byte-compile--for-effect 'for-effect-no-warn))
(byte-compile-warning-enabled-p (byte-compile-warning-enabled-p
@ -3598,6 +3538,26 @@ lambda-expression."
(byte-compile-discard)) (byte-compile-discard))
(pop byte-compile-form-stack))) (pop byte-compile-form-stack)))
(let ((important-return-value-fns
'(
;; These functions are side-effect-free except for the
;; behaviour of functions passed as argument.
mapcar mapcan mapconcat
assoc plist-get plist-member
;; It's safe to ignore the value of `sort' and `nreverse'
;; when used on arrays, but most calls pass lists.
nreverse sort
;; Adding these functions causes many warnings;
;; evaluate how many of them are false first.
;;delq delete
;;nconc plist-put
)))
(dolist (fn important-return-value-fns)
(put fn 'important-return-value t)))
(defun byte-compile-normal-call (form) (defun byte-compile-normal-call (form)
(when (and (symbolp (car form)) (when (and (symbolp (car form))
(byte-compile-warning-enabled-p 'callargs (car form))) (byte-compile-warning-enabled-p 'callargs (car form)))

View file

@ -3657,6 +3657,45 @@ macro that returns its `&whole' argument."
'(cl-list* cl-acons cl-equalp '(cl-list* cl-acons cl-equalp
cl-random-state-p copy-tree)) cl-random-state-p copy-tree))
;;; Things whose return value should probably be used.
(mapc (lambda (x) (function-put x 'important-return-value t))
'(
;; Functions that are side-effect-free except for the
;; behaviour of functions passed as argument.
cl-mapcar cl-mapcan cl-maplist cl-map cl-mapcon
cl-reduce
cl-assoc cl-assoc-if cl-assoc-if-not
cl-rassoc cl-rassoc-if cl-rassoc-if-not
cl-member cl-member-if cl-member-if-not
cl-adjoin
cl-mismatch cl-search
cl-find cl-find-if cl-find-if-not
cl-position cl-position-if cl-position-if-not
cl-count cl-count-if cl-count-if-not
cl-remove cl-remove-if cl-remove-if-not
cl-remove-duplicates
cl-subst cl-subst-if cl-subst-if-not
cl-substitute cl-substitute-if cl-substitute-if-not
cl-sublis
cl-union cl-intersection cl-set-difference cl-set-exclusive-or
cl-subsetp
cl-every cl-some cl-notevery cl-notany
cl-tree-equal
;; Functions that mutate and return a list.
cl-delete cl-delete-if cl-delete-if-not
cl-delete-duplicates
cl-nsubst cl-nsubst-if cl-nsubst-if-not
cl-nsubstitute cl-nsubstitute-if cl-nsubstitute-if-not
cl-nunion cl-nintersection cl-nset-difference cl-nset-exclusive-or
cl-nreconc cl-nsublis
cl-merge
;; It's safe to ignore the value of `cl-sort' and `cl-stable-sort'
;; when used on arrays, but most calls pass lists.
cl-sort cl-stable-sort
))
;;; Types and assertions. ;;; Types and assertions.
;;;###autoload ;;;###autoload

View file

@ -1001,13 +1001,14 @@ For BOL see `treesit-simple-indent-rules'."
(looking-at c-ts-mode--for-each-tail-regexp)))) (looking-at c-ts-mode--for-each-tail-regexp))))
(defvar c-ts-mode--emacs-c-range-query (defvar c-ts-mode--emacs-c-range-query
(treesit-query-compile (and (treesit-available-p)
'emacs-c `(((declaration (treesit-query-compile
type: (macro_type_specifier 'emacs-c `(((declaration
name: (identifier) @_name) type: (macro_type_specifier
@for-each-tail) name: (identifier) @_name)
(:match ,c-ts-mode--for-each-tail-regexp @for-each-tail)
@_name)))) (:match ,c-ts-mode--for-each-tail-regexp
@_name)))))
"Query that finds a FOR_EACH_* macro with an unbracketed body.") "Query that finds a FOR_EACH_* macro with an unbracketed body.")
(defvar-local c-ts-mode--for-each-tail-ranges nil (defvar-local c-ts-mode--for-each-tail-ranges nil

View file

@ -2720,8 +2720,7 @@ dedicated to the current buffer or its project (if one is found)."
(defmacro python-shell--add-to-path-with-priority (pathvar paths) (defmacro python-shell--add-to-path-with-priority (pathvar paths)
"Modify PATHVAR and ensure PATHS are added only once at beginning." "Modify PATHVAR and ensure PATHS are added only once at beginning."
`(dolist (path (reverse ,paths)) `(dolist (path (reverse ,paths))
(cl-delete path ,pathvar :test #'string=) (setq ,pathvar (cons path (cl-delete path ,pathvar :test #'string=)))))
(cl-pushnew path ,pathvar :test #'string=)))
(defun python-shell-calculate-pythonpath () (defun python-shell-calculate-pythonpath ()
"Calculate the PYTHONPATH using `python-shell-extra-pythonpaths'." "Calculate the PYTHONPATH using `python-shell-extra-pythonpaths'."

View file

@ -862,6 +862,7 @@ If that is non-nil, the element matches; then `assoc-default'
If no element matches, the value is nil. If no element matches, the value is nil.
If TEST is omitted or nil, `equal' is used." If TEST is omitted or nil, `equal' is used."
(declare (important-return-value t))
(let (found (tail alist) value) (let (found (tail alist) value)
(while (and tail (not found)) (while (and tail (not found))
(let ((elt (car tail))) (let ((elt (car tail)))