Merge from origin/emacs-30

98796f95fa Work on proced-tests.el
8a4d13e370 ; * doc/lispref/frames.texi (Yanking Media): Add index en...
0aae02a374 * lisp/files.el (require-with-check): Be a bit more lenie...
cc6a11f483 (with-peg-rules): Fix references to rulesets (bug#74018)
70f084db2f ; * etc/NEWS: Fix typo (bug#74066).
9e1abf11fc Tweak doc w.r.t to "void function" (bug#73886)
7a8ca202c5 Fix flakey proced refine tests (Bug#73441)
55a8cec013 Another 'void' update
This commit is contained in:
Eli Zaretskii 2024-11-02 08:34:42 -04:00
commit 9bc6362d6e
9 changed files with 97 additions and 43 deletions

View file

@ -4757,6 +4757,7 @@ to encoding or decoding by any coding system.
@node Yanking Media
@section Yanking Media
@cindex yank media from window-system selections
Data saved within window system selections is not restricted to
plain text. It is possible for selection data to encompass images or

View file

@ -1510,10 +1510,7 @@ indirect-function}.
@kindex void-function
This returns the object in the function cell of @var{symbol}. It does
not check that the returned object is a legitimate function.
If the function cell is void, the return value is @code{nil}. It is
impossible to distinguish between a function cell that is void and one
set to @code{nil}.
If the function is void, the return value is @code{nil}.
@example
@group
@ -1533,9 +1530,9 @@ set to @code{nil}.
@end defun
@cindex void function cell
If you have never given a symbol any function definition, we say
that that symbol's function cell is @dfn{void}. In other words, the
function cell does not have any Lisp object in it. If you try to call
If you have never given a symbol any function definition, its function
cell contains the default value @code{nil} and we say
that that function is @dfn{void}. If you try to call
the symbol as a function, Emacs signals a @code{void-function} error.
Unlike with void variables (@pxref{Void Variables}), a symbol's

View file

@ -100,11 +100,11 @@ the contents of a symbol's function cell, use the function
property list. To get a symbol's property list, use the function
@code{symbol-plist}. @xref{Symbol Properties}.
The function cell or the value cell may be @dfn{void}, which means
that the cell does not reference any object. (This is not the same
thing as holding the symbol @code{void}, nor the same as holding the
symbol @code{nil}.) Examining a function or value cell that is void
results in an error, such as @samp{Symbol's value as variable is void}.
The value cell may be @dfn{void}, which means that the cell does not
reference any object. (This is not the same thing as holding the symbol
@code{void}, nor the same as holding the symbol @code{nil}.) Examining
a value cell that is void results in an error, such as @samp{Symbol's
value as variable is void}.
Because each symbol has separate value and function cells, variables
names and function names do not conflict. For example, the symbol

View file

@ -33,7 +33,7 @@ incorrectly in rare cases.
---
** New configuration option '--disable-gc-mark-trace'.
This disables the GC mark trace buffer for about 5 % better garbage
This disables the GC mark trace buffer for about 5% better garbage
collection performance. Doing so may make it more difficult for Emacs
developers to help finding GC-related bugs that you run into, which is
why the mark trace buffer is enabled by default.

View file

@ -1276,10 +1276,27 @@ NOERROR is equal to `reload'), or otherwise emit a warning."
;; file, so we're done.
(when (eq lh load-history)
;; If `require' did nothing, we need to make sure that was warranted.
(let ((fn (locate-file (or filename (symbol-name feature))
load-path (get-load-suffixes))))
(let* ((fn (locate-file (or filename (symbol-name feature))
load-path (get-load-suffixes) nil
)) ;; load-prefer-newer
;; We used to look for `fn' in `load-history' with `assoc'
;; which works in most cases, but in some cases (e.g. when
;; `load-prefer-newer' is set) `locate-file' can return a
;; different file than the file that `require' would load,
;; so the file won't be found in `load-history' even though
;; we did load "it". (bug#74040)
;; So use a "permissive" search which doesn't pay attention to
;; differences between file extensions.
(prefix (if (string-match
(concat (regexp-opt (get-load-suffixes)) "\\'") fn)
(concat (substring fn 0 (match-beginning 0)) ".")
fn))
(lh load-history))
(while (and lh (let ((file (car-safe (car lh))))
(not (and file (string-prefix-p prefix file)))))
(setq lh (cdr lh)))
(cond
((assoc fn load-history) nil) ;We loaded the right file.
(lh nil) ;We loaded the right file.
((eq noerror 'reload) (load fn nil 'nomessage))
((and fn (memq feature features))
(let ((oldfile (symbol-file feature 'provide)))

View file

@ -412,6 +412,7 @@ sequencing `and' operator of PEG grammars."
(full-rname (format "%s %s" name rname)))
(push `(define-peg-rule ,full-rname . ,(cdr rule)) defs)
(push `(,(peg--rule-id rname) #',(peg--rule-id full-rname)) aliases)))
(require 'cl-lib)
`(cl-flet ,aliases
,@defs
(eval-and-compile (put ',name 'peg--rules ',aliases)))))
@ -432,7 +433,8 @@ rulesets defined previously with `define-peg-ruleset'."
(progn (push rule rulesets) nil)
(cons (car rule) (peg-normalize `(and . ,(cdr rule))))))
rules)))
(ctx (assq :peg-rules macroexpand-all-environment)))
(ctx (assq :peg-rules macroexpand-all-environment))
(body
(macroexpand-all
`(cl-labels
,(mapcar (lambda (rule)
@ -444,6 +446,15 @@ rulesets defined previously with `define-peg-ruleset'."
,@body)
`((:peg-rules ,@(append rules (cdr ctx)))
,@macroexpand-all-environment))))
(if (null rulesets)
body
`(cl-flet ,(mapcan (lambda (ruleset)
(let ((aliases (get ruleset 'peg--rules)))
(unless aliases
(message "Unknown PEG ruleset: %S" ruleset))
(copy-sequence aliases)))
rulesets)
,body))))
;;;;; Old entry points
@ -645,7 +656,7 @@ rulesets defined previously with `define-peg-ruleset'."
(code (peg-translate-exp exp)))
(cond
((null msg) code)
(t (macroexp-warn-and-return msg code)))))
(t (macroexp-warn-and-return msg code 'peg nil exp)))))
;; This is the main translation function.
(defun peg-translate-exp (exp)

View file

@ -756,7 +756,7 @@ global value outside of any lexical scope. */)
breaking backward compatibility, as some users of fboundp may
expect t in particular, rather than any true value. */
DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0,
doc: /* Return t if SYMBOL's function definition is neither void nor nil. */)
doc: /* Return t if SYMBOL's function definition is not nil. */)
(Lisp_Object symbol)
{
CHECK_SYMBOL (symbol);
@ -785,7 +785,7 @@ DEFUN ("fmakunbound", Ffmakunbound, Sfmakunbound, 1, 1, 0,
doc: /* Make SYMBOL's function definition be nil.
Return SYMBOL.
If a function definition is nil or void, trying to call a function by
If a function definition is nil, trying to call a function by
that name will cause a `void-function' error. For more details, see
Info node `(elisp) Function Cells'.
@ -800,7 +800,7 @@ See also `makunbound'. */)
}
DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0,
doc: /* Return SYMBOL's function definition, or nil if that is void or nil. */)
doc: /* Return SYMBOL's function definition. */)
(Lisp_Object symbol)
{
CHECK_SYMBOL (symbol);

View file

@ -43,18 +43,31 @@
(defun proced--move-to-column (attribute)
"Move to the column under ATTRIBUTE in the current proced buffer."
(move-to-column (string-match attribute proced-header-line)))
(move-to-column (string-match attribute proced-header-line))
;; Sometimes the column entry does not fill the whole column.
(while (= (char-after (point)) ?\s) (forward-char)))
(defun proced--assert-process-valid-pid-refinement (pid)
"Fail unless the process at point could be present after a refinement using PID."
(proced--move-to-column "PID")
(let ((pid-equal (string= pid (word-at-point))))
(should
(or pid-equal
;; Guard against the unlikely event a platform doesn't support PPID
(when (string-match "PPID" proced-header-line)
(proced--move-to-column "PPID")
(string= pid (word-at-point)))))))
(defun proced--assert-process-valid-cpu-refinement (cpu)
"Fail unless the process at point could be present after a refinement using CPU."
(proced--move-to-column "%CPU")
(>= (thing-at-point 'number) cpu))
(defun proced--assert-process-valid-cpu-refinement-explainer (cpu)
"Explain the result of `proced--assert-process-valid-cpu-refinement'.
CPU is as in `proced--assert-process-valid-cpu-refinement'."
`(unexpected-refinement
(header-line
,(substring-no-properties
(string-replace "%%" "%" (cadr (proced-header-line)))))
(process ,(thing-at-point 'line t))
(refined-value ,cpu)
(process-value
,(save-excursion
(proced--move-to-column "%CPU") (thing-at-point 'number)))))
(put #'proced--assert-process-valid-cpu-refinement 'ert-explainer
#'proced--assert-process-valid-cpu-refinement-explainer)
(ert-deftest proced-format-test ()
(dolist (format '(short medium long verbose))
@ -85,26 +98,24 @@
(proced--assert-emacs-pid-in-buffer))))
(ert-deftest proced-refine-test ()
;;(skip-unless (memq system-type '(gnu/linux gnu/kfreebsd darwin)))
(proced--within-buffer
'verbose
'user
;; When refining on PID for process A, a process is kept if and only
;; if its PID is the same as process A, or its parent process is
;; process A.
(proced--move-to-column "PID")
(let ((pid (word-at-point)))
;; When refining on %CPU for process A, a process is kept if and only
;; if its %CPU is greater than or equal to that of process A.
(proced--move-to-column "%CPU")
(let ((cpu (thing-at-point 'number)))
(proced-refine)
(while (not (eobp))
(proced--assert-process-valid-pid-refinement pid)
(should (proced--assert-process-valid-cpu-refinement cpu))
(forward-line)))))
(ert-deftest proced-refine-with-update-test ()
(proced--within-buffer
'verbose
'user
(proced--move-to-column "PID")
(let ((pid (word-at-point)))
(proced--move-to-column "%CPU")
(let ((cpu (thing-at-point 'number)))
(proced-refine)
;; Don't use (proced-update t) since this will reset `proced-process-alist'
;; and it's possible the process refined on would have exited by that
@ -112,10 +123,13 @@
;; processes again, causing the test to fail.
(proced-update)
(while (not (eobp))
(proced--assert-process-valid-pid-refinement pid)
(should (proced--assert-process-valid-cpu-refinement cpu))
(forward-line)))))
(ert-deftest proced-update-preserves-pid-at-point-test ()
;; FIXME: Occasionally the cursor inexplicably changes to the first line which
;; causes the test to file when the line isn't the Emacs process.
:tags '(:unstable)
(proced--within-buffer
'medium
'user
@ -128,7 +142,7 @@
(old-window (get-buffer-window)))
(select-window new-window)
(with-current-buffer "*Proced*"
(proced-update t t))
(proced-update))
(select-window old-window)
(should (= pid (proced-pid-at-point)))))))

View file

@ -180,6 +180,20 @@ resp. succeeded instead of signaling an error."
(should (eobp)))
)
(define-peg-ruleset peg-test-myrules
(sign () (or "+" "-" ""))
(digit () [0-9])
(nat () digit (* digit))
(int () sign digit (* digit))
(float () int "." nat))
(ert-deftest peg-test-ruleset ()
(with-peg-rules
(peg-test-myrules
(complex float "+i" float))
(should (peg-parse-string nat "123" t))
(should (not (peg-parse-string nat "home" t)))))
;;; Examples:
;; peg-ex-recognize-int recognizes integers. An integer begins with a