diff options
| author | Eli Zaretskii | 2024-11-02 08:34:42 -0400 |
|---|---|---|
| committer | Eli Zaretskii | 2024-11-02 08:34:42 -0400 |
| commit | 9bc6362d6e43e99cfe2dea8748e29e63c65985c0 (patch) | |
| tree | 147ec9ea92222a38833cb0cef79ef567d14df682 | |
| parent | 74d3232522f762742e9acaf9e62b9fd6d63ae380 (diff) | |
| parent | 98796f95fa5ce7c38074429517c477cd01b0be37 (diff) | |
| download | emacs-9bc6362d6e43e99cfe2dea8748e29e63c65985c0.tar.gz emacs-9bc6362d6e43e99cfe2dea8748e29e63c65985c0.zip | |
Merge from origin/emacs-30
98796f95fa5 Work on proced-tests.el
8a4d13e370c ; * doc/lispref/frames.texi (Yanking Media): Add index en...
0aae02a3741 * lisp/files.el (require-with-check): Be a bit more lenie...
cc6a11f4832 (with-peg-rules): Fix references to rulesets (bug#74018)
70f084db2ff ; * etc/NEWS: Fix typo (bug#74066).
9e1abf11fc1 Tweak doc w.r.t to "void function" (bug#73886)
7a8ca202c5e Fix flakey proced refine tests (Bug#73441)
55a8cec013e Another 'void' update
| -rw-r--r-- | doc/lispref/frames.texi | 1 | ||||
| -rw-r--r-- | doc/lispref/functions.texi | 11 | ||||
| -rw-r--r-- | doc/lispref/symbols.texi | 10 | ||||
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/files.el | 23 | ||||
| -rw-r--r-- | lisp/progmodes/peg.el | 15 | ||||
| -rw-r--r-- | src/data.c | 6 | ||||
| -rw-r--r-- | test/lisp/proced-tests.el | 60 | ||||
| -rw-r--r-- | test/lisp/progmodes/peg-tests.el | 14 |
9 files changed, 98 insertions, 44 deletions
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index edeba3288fc..1b463eb51e5 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi | |||
| @@ -4757,6 +4757,7 @@ to encoding or decoding by any coding system. | |||
| 4757 | 4757 | ||
| 4758 | @node Yanking Media | 4758 | @node Yanking Media |
| 4759 | @section Yanking Media | 4759 | @section Yanking Media |
| 4760 | @cindex yank media from window-system selections | ||
| 4760 | 4761 | ||
| 4761 | Data saved within window system selections is not restricted to | 4762 | Data saved within window system selections is not restricted to |
| 4762 | plain text. It is possible for selection data to encompass images or | 4763 | plain text. It is possible for selection data to encompass images or |
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index db2c4197144..bf80a21ee9f 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi | |||
| @@ -1510,10 +1510,7 @@ indirect-function}. | |||
| 1510 | @kindex void-function | 1510 | @kindex void-function |
| 1511 | This returns the object in the function cell of @var{symbol}. It does | 1511 | This returns the object in the function cell of @var{symbol}. It does |
| 1512 | not check that the returned object is a legitimate function. | 1512 | not check that the returned object is a legitimate function. |
| 1513 | 1513 | If the function is void, the return value is @code{nil}. | |
| 1514 | If the function cell is void, the return value is @code{nil}. It is | ||
| 1515 | impossible to distinguish between a function cell that is void and one | ||
| 1516 | set to @code{nil}. | ||
| 1517 | 1514 | ||
| 1518 | @example | 1515 | @example |
| 1519 | @group | 1516 | @group |
| @@ -1533,9 +1530,9 @@ set to @code{nil}. | |||
| 1533 | @end defun | 1530 | @end defun |
| 1534 | 1531 | ||
| 1535 | @cindex void function cell | 1532 | @cindex void function cell |
| 1536 | If you have never given a symbol any function definition, we say | 1533 | If you have never given a symbol any function definition, its function |
| 1537 | that that symbol's function cell is @dfn{void}. In other words, the | 1534 | cell contains the default value @code{nil} and we say |
| 1538 | function cell does not have any Lisp object in it. If you try to call | 1535 | that that function is @dfn{void}. If you try to call |
| 1539 | the symbol as a function, Emacs signals a @code{void-function} error. | 1536 | the symbol as a function, Emacs signals a @code{void-function} error. |
| 1540 | 1537 | ||
| 1541 | Unlike with void variables (@pxref{Void Variables}), a symbol's | 1538 | Unlike with void variables (@pxref{Void Variables}), a symbol's |
diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi index c76bf3d3820..c3dc08df2df 100644 --- a/doc/lispref/symbols.texi +++ b/doc/lispref/symbols.texi | |||
| @@ -100,11 +100,11 @@ the contents of a symbol's function cell, use the function | |||
| 100 | property list. To get a symbol's property list, use the function | 100 | property list. To get a symbol's property list, use the function |
| 101 | @code{symbol-plist}. @xref{Symbol Properties}. | 101 | @code{symbol-plist}. @xref{Symbol Properties}. |
| 102 | 102 | ||
| 103 | The function cell or the value cell may be @dfn{void}, which means | 103 | The value cell may be @dfn{void}, which means that the cell does not |
| 104 | that the cell does not reference any object. (This is not the same | 104 | reference any object. (This is not the same thing as holding the symbol |
| 105 | thing as holding the symbol @code{void}, nor the same as holding the | 105 | @code{void}, nor the same as holding the symbol @code{nil}.) Examining |
| 106 | symbol @code{nil}.) Examining a function or value cell that is void | 106 | a value cell that is void results in an error, such as @samp{Symbol's |
| 107 | results in an error, such as @samp{Symbol's value as variable is void}. | 107 | value as variable is void}. |
| 108 | 108 | ||
| 109 | Because each symbol has separate value and function cells, variables | 109 | Because each symbol has separate value and function cells, variables |
| 110 | names and function names do not conflict. For example, the symbol | 110 | names and function names do not conflict. For example, the symbol |
| @@ -33,7 +33,7 @@ incorrectly in rare cases. | |||
| 33 | 33 | ||
| 34 | --- | 34 | --- |
| 35 | ** New configuration option '--disable-gc-mark-trace'. | 35 | ** New configuration option '--disable-gc-mark-trace'. |
| 36 | This disables the GC mark trace buffer for about 5 % better garbage | 36 | This disables the GC mark trace buffer for about 5% better garbage |
| 37 | collection performance. Doing so may make it more difficult for Emacs | 37 | collection performance. Doing so may make it more difficult for Emacs |
| 38 | developers to help finding GC-related bugs that you run into, which is | 38 | developers to help finding GC-related bugs that you run into, which is |
| 39 | why the mark trace buffer is enabled by default. | 39 | why the mark trace buffer is enabled by default. |
diff --git a/lisp/files.el b/lisp/files.el index 9c105dbe1a5..54f2397ee37 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -1276,10 +1276,27 @@ NOERROR is equal to `reload'), or otherwise emit a warning." | |||
| 1276 | ;; file, so we're done. | 1276 | ;; file, so we're done. |
| 1277 | (when (eq lh load-history) | 1277 | (when (eq lh load-history) |
| 1278 | ;; If `require' did nothing, we need to make sure that was warranted. | 1278 | ;; If `require' did nothing, we need to make sure that was warranted. |
| 1279 | (let ((fn (locate-file (or filename (symbol-name feature)) | 1279 | (let* ((fn (locate-file (or filename (symbol-name feature)) |
| 1280 | load-path (get-load-suffixes)))) | 1280 | load-path (get-load-suffixes) nil |
| 1281 | )) ;; load-prefer-newer | ||
| 1282 | ;; We used to look for `fn' in `load-history' with `assoc' | ||
| 1283 | ;; which works in most cases, but in some cases (e.g. when | ||
| 1284 | ;; `load-prefer-newer' is set) `locate-file' can return a | ||
| 1285 | ;; different file than the file that `require' would load, | ||
| 1286 | ;; so the file won't be found in `load-history' even though | ||
| 1287 | ;; we did load "it". (bug#74040) | ||
| 1288 | ;; So use a "permissive" search which doesn't pay attention to | ||
| 1289 | ;; differences between file extensions. | ||
| 1290 | (prefix (if (string-match | ||
| 1291 | (concat (regexp-opt (get-load-suffixes)) "\\'") fn) | ||
| 1292 | (concat (substring fn 0 (match-beginning 0)) ".") | ||
| 1293 | fn)) | ||
| 1294 | (lh load-history)) | ||
| 1295 | (while (and lh (let ((file (car-safe (car lh)))) | ||
| 1296 | (not (and file (string-prefix-p prefix file))))) | ||
| 1297 | (setq lh (cdr lh))) | ||
| 1281 | (cond | 1298 | (cond |
| 1282 | ((assoc fn load-history) nil) ;We loaded the right file. | 1299 | (lh nil) ;We loaded the right file. |
| 1283 | ((eq noerror 'reload) (load fn nil 'nomessage)) | 1300 | ((eq noerror 'reload) (load fn nil 'nomessage)) |
| 1284 | ((and fn (memq feature features)) | 1301 | ((and fn (memq feature features)) |
| 1285 | (let ((oldfile (symbol-file feature 'provide))) | 1302 | (let ((oldfile (symbol-file feature 'provide))) |
diff --git a/lisp/progmodes/peg.el b/lisp/progmodes/peg.el index 96334162195..0b069e95563 100644 --- a/lisp/progmodes/peg.el +++ b/lisp/progmodes/peg.el | |||
| @@ -412,6 +412,7 @@ sequencing `and' operator of PEG grammars." | |||
| 412 | (full-rname (format "%s %s" name rname))) | 412 | (full-rname (format "%s %s" name rname))) |
| 413 | (push `(define-peg-rule ,full-rname . ,(cdr rule)) defs) | 413 | (push `(define-peg-rule ,full-rname . ,(cdr rule)) defs) |
| 414 | (push `(,(peg--rule-id rname) #',(peg--rule-id full-rname)) aliases))) | 414 | (push `(,(peg--rule-id rname) #',(peg--rule-id full-rname)) aliases))) |
| 415 | (require 'cl-lib) | ||
| 415 | `(cl-flet ,aliases | 416 | `(cl-flet ,aliases |
| 416 | ,@defs | 417 | ,@defs |
| 417 | (eval-and-compile (put ',name 'peg--rules ',aliases))))) | 418 | (eval-and-compile (put ',name 'peg--rules ',aliases))))) |
| @@ -432,7 +433,8 @@ rulesets defined previously with `define-peg-ruleset'." | |||
| 432 | (progn (push rule rulesets) nil) | 433 | (progn (push rule rulesets) nil) |
| 433 | (cons (car rule) (peg-normalize `(and . ,(cdr rule)))))) | 434 | (cons (car rule) (peg-normalize `(and . ,(cdr rule)))))) |
| 434 | rules))) | 435 | rules))) |
| 435 | (ctx (assq :peg-rules macroexpand-all-environment))) | 436 | (ctx (assq :peg-rules macroexpand-all-environment)) |
| 437 | (body | ||
| 436 | (macroexpand-all | 438 | (macroexpand-all |
| 437 | `(cl-labels | 439 | `(cl-labels |
| 438 | ,(mapcar (lambda (rule) | 440 | ,(mapcar (lambda (rule) |
| @@ -444,6 +446,15 @@ rulesets defined previously with `define-peg-ruleset'." | |||
| 444 | ,@body) | 446 | ,@body) |
| 445 | `((:peg-rules ,@(append rules (cdr ctx))) | 447 | `((:peg-rules ,@(append rules (cdr ctx))) |
| 446 | ,@macroexpand-all-environment)))) | 448 | ,@macroexpand-all-environment)))) |
| 449 | (if (null rulesets) | ||
| 450 | body | ||
| 451 | `(cl-flet ,(mapcan (lambda (ruleset) | ||
| 452 | (let ((aliases (get ruleset 'peg--rules))) | ||
| 453 | (unless aliases | ||
| 454 | (message "Unknown PEG ruleset: %S" ruleset)) | ||
| 455 | (copy-sequence aliases))) | ||
| 456 | rulesets) | ||
| 457 | ,body)))) | ||
| 447 | 458 | ||
| 448 | ;;;;; Old entry points | 459 | ;;;;; Old entry points |
| 449 | 460 | ||
| @@ -645,7 +656,7 @@ rulesets defined previously with `define-peg-ruleset'." | |||
| 645 | (code (peg-translate-exp exp))) | 656 | (code (peg-translate-exp exp))) |
| 646 | (cond | 657 | (cond |
| 647 | ((null msg) code) | 658 | ((null msg) code) |
| 648 | (t (macroexp-warn-and-return msg code))))) | 659 | (t (macroexp-warn-and-return msg code 'peg nil exp))))) |
| 649 | 660 | ||
| 650 | ;; This is the main translation function. | 661 | ;; This is the main translation function. |
| 651 | (defun peg-translate-exp (exp) | 662 | (defun peg-translate-exp (exp) |
diff --git a/src/data.c b/src/data.c index 73dd2f5d4ed..66cf34c1e60 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -756,7 +756,7 @@ global value outside of any lexical scope. */) | |||
| 756 | breaking backward compatibility, as some users of fboundp may | 756 | breaking backward compatibility, as some users of fboundp may |
| 757 | expect t in particular, rather than any true value. */ | 757 | expect t in particular, rather than any true value. */ |
| 758 | DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0, | 758 | DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0, |
| 759 | doc: /* Return t if SYMBOL's function definition is neither void nor nil. */) | 759 | doc: /* Return t if SYMBOL's function definition is not nil. */) |
| 760 | (Lisp_Object symbol) | 760 | (Lisp_Object symbol) |
| 761 | { | 761 | { |
| 762 | CHECK_SYMBOL (symbol); | 762 | CHECK_SYMBOL (symbol); |
| @@ -785,7 +785,7 @@ DEFUN ("fmakunbound", Ffmakunbound, Sfmakunbound, 1, 1, 0, | |||
| 785 | doc: /* Make SYMBOL's function definition be nil. | 785 | doc: /* Make SYMBOL's function definition be nil. |
| 786 | Return SYMBOL. | 786 | Return SYMBOL. |
| 787 | 787 | ||
| 788 | If a function definition is nil or void, trying to call a function by | 788 | If a function definition is nil, trying to call a function by |
| 789 | that name will cause a `void-function' error. For more details, see | 789 | that name will cause a `void-function' error. For more details, see |
| 790 | Info node `(elisp) Function Cells'. | 790 | Info node `(elisp) Function Cells'. |
| 791 | 791 | ||
| @@ -800,7 +800,7 @@ See also `makunbound'. */) | |||
| 800 | } | 800 | } |
| 801 | 801 | ||
| 802 | DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0, | 802 | DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0, |
| 803 | doc: /* Return SYMBOL's function definition, or nil if that is void or nil. */) | 803 | doc: /* Return SYMBOL's function definition. */) |
| 804 | (Lisp_Object symbol) | 804 | (Lisp_Object symbol) |
| 805 | { | 805 | { |
| 806 | CHECK_SYMBOL (symbol); | 806 | CHECK_SYMBOL (symbol); |
diff --git a/test/lisp/proced-tests.el b/test/lisp/proced-tests.el index 6f16a241146..9036c15271c 100644 --- a/test/lisp/proced-tests.el +++ b/test/lisp/proced-tests.el | |||
| @@ -43,18 +43,31 @@ | |||
| 43 | 43 | ||
| 44 | (defun proced--move-to-column (attribute) | 44 | (defun proced--move-to-column (attribute) |
| 45 | "Move to the column under ATTRIBUTE in the current proced buffer." | 45 | "Move to the column under ATTRIBUTE in the current proced buffer." |
| 46 | (move-to-column (string-match attribute proced-header-line))) | 46 | (move-to-column (string-match attribute proced-header-line)) |
| 47 | 47 | ;; Sometimes the column entry does not fill the whole column. | |
| 48 | (defun proced--assert-process-valid-pid-refinement (pid) | 48 | (while (= (char-after (point)) ?\s) (forward-char))) |
| 49 | "Fail unless the process at point could be present after a refinement using PID." | 49 | |
| 50 | (proced--move-to-column "PID") | 50 | (defun proced--assert-process-valid-cpu-refinement (cpu) |
| 51 | (let ((pid-equal (string= pid (word-at-point)))) | 51 | "Fail unless the process at point could be present after a refinement using CPU." |
| 52 | (should | 52 | (proced--move-to-column "%CPU") |
| 53 | (or pid-equal | 53 | (>= (thing-at-point 'number) cpu)) |
| 54 | ;; Guard against the unlikely event a platform doesn't support PPID | 54 | |
| 55 | (when (string-match "PPID" proced-header-line) | 55 | (defun proced--assert-process-valid-cpu-refinement-explainer (cpu) |
| 56 | (proced--move-to-column "PPID") | 56 | "Explain the result of `proced--assert-process-valid-cpu-refinement'. |
| 57 | (string= pid (word-at-point))))))) | 57 | |
| 58 | CPU is as in `proced--assert-process-valid-cpu-refinement'." | ||
| 59 | `(unexpected-refinement | ||
| 60 | (header-line | ||
| 61 | ,(substring-no-properties | ||
| 62 | (string-replace "%%" "%" (cadr (proced-header-line))))) | ||
| 63 | (process ,(thing-at-point 'line t)) | ||
| 64 | (refined-value ,cpu) | ||
| 65 | (process-value | ||
| 66 | ,(save-excursion | ||
| 67 | (proced--move-to-column "%CPU") (thing-at-point 'number))))) | ||
| 68 | |||
| 69 | (put #'proced--assert-process-valid-cpu-refinement 'ert-explainer | ||
| 70 | #'proced--assert-process-valid-cpu-refinement-explainer) | ||
| 58 | 71 | ||
| 59 | (ert-deftest proced-format-test () | 72 | (ert-deftest proced-format-test () |
| 60 | (dolist (format '(short medium long verbose)) | 73 | (dolist (format '(short medium long verbose)) |
| @@ -85,26 +98,24 @@ | |||
| 85 | (proced--assert-emacs-pid-in-buffer)))) | 98 | (proced--assert-emacs-pid-in-buffer)))) |
| 86 | 99 | ||
| 87 | (ert-deftest proced-refine-test () | 100 | (ert-deftest proced-refine-test () |
| 88 | ;;(skip-unless (memq system-type '(gnu/linux gnu/kfreebsd darwin))) | ||
| 89 | (proced--within-buffer | 101 | (proced--within-buffer |
| 90 | 'verbose | 102 | 'verbose |
| 91 | 'user | 103 | 'user |
| 92 | ;; When refining on PID for process A, a process is kept if and only | 104 | ;; When refining on %CPU for process A, a process is kept if and only |
| 93 | ;; if its PID is the same as process A, or its parent process is | 105 | ;; if its %CPU is greater than or equal to that of process A. |
| 94 | ;; process A. | 106 | (proced--move-to-column "%CPU") |
| 95 | (proced--move-to-column "PID") | 107 | (let ((cpu (thing-at-point 'number))) |
| 96 | (let ((pid (word-at-point))) | ||
| 97 | (proced-refine) | 108 | (proced-refine) |
| 98 | (while (not (eobp)) | 109 | (while (not (eobp)) |
| 99 | (proced--assert-process-valid-pid-refinement pid) | 110 | (should (proced--assert-process-valid-cpu-refinement cpu)) |
| 100 | (forward-line))))) | 111 | (forward-line))))) |
| 101 | 112 | ||
| 102 | (ert-deftest proced-refine-with-update-test () | 113 | (ert-deftest proced-refine-with-update-test () |
| 103 | (proced--within-buffer | 114 | (proced--within-buffer |
| 104 | 'verbose | 115 | 'verbose |
| 105 | 'user | 116 | 'user |
| 106 | (proced--move-to-column "PID") | 117 | (proced--move-to-column "%CPU") |
| 107 | (let ((pid (word-at-point))) | 118 | (let ((cpu (thing-at-point 'number))) |
| 108 | (proced-refine) | 119 | (proced-refine) |
| 109 | ;; Don't use (proced-update t) since this will reset `proced-process-alist' | 120 | ;; Don't use (proced-update t) since this will reset `proced-process-alist' |
| 110 | ;; and it's possible the process refined on would have exited by that | 121 | ;; and it's possible the process refined on would have exited by that |
| @@ -112,10 +123,13 @@ | |||
| 112 | ;; processes again, causing the test to fail. | 123 | ;; processes again, causing the test to fail. |
| 113 | (proced-update) | 124 | (proced-update) |
| 114 | (while (not (eobp)) | 125 | (while (not (eobp)) |
| 115 | (proced--assert-process-valid-pid-refinement pid) | 126 | (should (proced--assert-process-valid-cpu-refinement cpu)) |
| 116 | (forward-line))))) | 127 | (forward-line))))) |
| 117 | 128 | ||
| 118 | (ert-deftest proced-update-preserves-pid-at-point-test () | 129 | (ert-deftest proced-update-preserves-pid-at-point-test () |
| 130 | ;; FIXME: Occasionally the cursor inexplicably changes to the first line which | ||
| 131 | ;; causes the test to file when the line isn't the Emacs process. | ||
| 132 | :tags '(:unstable) | ||
| 119 | (proced--within-buffer | 133 | (proced--within-buffer |
| 120 | 'medium | 134 | 'medium |
| 121 | 'user | 135 | 'user |
| @@ -128,7 +142,7 @@ | |||
| 128 | (old-window (get-buffer-window))) | 142 | (old-window (get-buffer-window))) |
| 129 | (select-window new-window) | 143 | (select-window new-window) |
| 130 | (with-current-buffer "*Proced*" | 144 | (with-current-buffer "*Proced*" |
| 131 | (proced-update t t)) | 145 | (proced-update)) |
| 132 | (select-window old-window) | 146 | (select-window old-window) |
| 133 | (should (= pid (proced-pid-at-point))))))) | 147 | (should (= pid (proced-pid-at-point))))))) |
| 134 | 148 | ||
diff --git a/test/lisp/progmodes/peg-tests.el b/test/lisp/progmodes/peg-tests.el index 8fab549bcab..b9e9c47ab7c 100644 --- a/test/lisp/progmodes/peg-tests.el +++ b/test/lisp/progmodes/peg-tests.el | |||
| @@ -180,6 +180,20 @@ resp. succeeded instead of signaling an error." | |||
| 180 | (should (eobp))) | 180 | (should (eobp))) |
| 181 | ) | 181 | ) |
| 182 | 182 | ||
| 183 | (define-peg-ruleset peg-test-myrules | ||
| 184 | (sign () (or "+" "-" "")) | ||
| 185 | (digit () [0-9]) | ||
| 186 | (nat () digit (* digit)) | ||
| 187 | (int () sign digit (* digit)) | ||
| 188 | (float () int "." nat)) | ||
| 189 | |||
| 190 | (ert-deftest peg-test-ruleset () | ||
| 191 | (with-peg-rules | ||
| 192 | (peg-test-myrules | ||
| 193 | (complex float "+i" float)) | ||
| 194 | (should (peg-parse-string nat "123" t)) | ||
| 195 | (should (not (peg-parse-string nat "home" t))))) | ||
| 196 | |||
| 183 | ;;; Examples: | 197 | ;;; Examples: |
| 184 | 198 | ||
| 185 | ;; peg-ex-recognize-int recognizes integers. An integer begins with a | 199 | ;; peg-ex-recognize-int recognizes integers. An integer begins with a |