commit 7755f7172748b2d337fa53434c1f678269cc5c45 (HEAD, refs/remotes/origin/master) Author: Juri Linkov Date: Wed Jan 10 09:34:47 2024 +0200 Support :category in completion-extra-properties (bug#68214) * doc/lispref/minibuf.texi (Completion Variables): Add :category to the table of completion-extra-properties. * lisp/minibuffer.el (completion--metadata-get-1): New internal function. (completion-metadata-get): Use 'completion--metadata-get-1'. Thanks to Daniel Mendler . (completion-extra-properties): Mention :category in the docstring. * lisp/calendar/calendar.el (calendar-read-date): Use more user-friendly let-binding of completion-extra-properties with :category. diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 18df44256a8..aa27de72ba0 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -1912,6 +1912,12 @@ completion commands. Its value should be a list of property and value pairs. The following properties are supported: @table @code +@item :category +The value should be a symbol describing what kind of text the +completion function is trying to complete. If the symbol matches one +of the keys in @code{completion-category-overrides}, the usual +completion behavior is overridden. @xref{Completion Variables}. + @item :annotation-function The value should be a function to add annotations in the completions buffer. This function must accept one argument, a completion, and diff --git a/etc/NEWS b/etc/NEWS index fcec2ca715a..4559c67d4ae 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -754,8 +754,8 @@ defined in completion metadata. +++ *** 'completion-extra-properties' supports more metadata. -The new supported completion properties are 'group-function', -'display-sort-function', 'cycle-sort-function'. +The new supported completion properties are 'category', +'group-function', 'display-sort-function', 'cycle-sort-function'. ** Pcomplete diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index e01d5d792a6..2c3e7d28301 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el @@ -2337,14 +2337,12 @@ returned is (month year)." (defmon (aref month-array (1- (calendar-extract-month default-date)))) (completion-ignore-case t) (month (cdr (assoc-string - (completing-read - (format-prompt "Month name" defmon) - (lambda (string pred action) - (if (eq action 'metadata) - '(metadata (category . calendar-month)) - (complete-with-action - action (append month-array nil) string pred))) - nil t nil nil defmon) + (let ((completion-extra-properties + '(:category calendar-month))) + (completing-read + (format-prompt "Month name" defmon) + (append month-array nil) + nil t nil nil defmon)) (calendar-make-alist month-array 1) t))) (defday (calendar-extract-day default-date)) (last (calendar-last-day-of-month month year))) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 42d04e0ff96..45aab398078 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -150,6 +150,14 @@ The metadata of a completion table should be constant between two boundaries." minibuffer-completion-table minibuffer-completion-predicate)) +(defun completion--metadata-get-1 (metadata prop) + (or (alist-get prop metadata) + (plist-get completion-extra-properties + ;; Cache the keyword + (or (get prop 'completion-extra-properties--keyword) + (put prop 'completion-extra-properties--keyword + (intern (concat ":" (symbol-name prop)))))))) + (defun completion-metadata-get (metadata prop) "Get property PROP from completion METADATA. If the metadata specifies a completion category, the variables @@ -161,15 +169,10 @@ consulted. Note that the keys of the `completion-extra-properties' plist are keyword symbols, not plain symbols." (if-let (((not (eq prop 'category))) - (cat (alist-get 'category metadata)) + (cat (completion--metadata-get-1 metadata 'category)) (over (completion--category-override cat prop))) (cdr over) - (or (alist-get prop metadata) - (plist-get completion-extra-properties - ;; Cache the keyword - (or (get prop 'completion-extra-properties--keyword) - (put prop 'completion-extra-properties--keyword - (intern (concat ":" (symbol-name prop))))))))) + (completion--metadata-get-1 metadata prop))) (defun complete-with-action (action collection string predicate) "Perform completion according to ACTION. @@ -2442,6 +2445,9 @@ candidates." "Property list of extra properties of the current completion job. These include: +`:category': the kind of objects returned by `all-completions'. + Used by `completion-category-overrides'. + `:annotation-function': Function to annotate the completions buffer. The function must accept one argument, a completion string, and return either nil or a string which is to be displayed commit 3f303b9cb51306e1f70e2024a31a48a9901585a0 Author: Po Lu Date: Wed Jan 10 11:38:54 2024 +0800 ; Minor edits to PROBLEMS and sfnt.c * etc/PROBLEMS: Improve description of issues with Droid Sans Mono. * src/sfnt.c (sfnt_poly_edges_exact): Remove extraneous undef. diff --git a/etc/PROBLEMS b/etc/PROBLEMS index 7a5f029af65..5166907e463 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -3408,14 +3408,15 @@ this and many other problems do not exist on the regular X builds. TrueType fonts incorporate instruction code executed by the font scaler (the component responsible for transforming outlines into -bitmap images capable of being displayed onscreen), in order that -features of each glyph might be aligned to pixel boundaries -intelligently, preventing faintness while maintaining the shape of its -features. The substandard instruction code provided by the monospace -font distributed with Android misplaces features of such glyphs as "E" -and "F" between point sizes of 16 and 24, resulting in noticeable +bitmap images capable of being displayed onscreen) to align features +of each glyph to pixel boundaries while maintaining their shape, in +order to alleviate visual imperfections produced by scaling. The +substandard instruction code provided by the Android "Droid Sans Mono" +font misplaces features of glyphs containing, as components, "E" and +"F", between PPEM sizes of 16 and 24, resulting in noticeable whitespace inconsistencies with other glyphs. Furthermore, the -vertical stem in the glyph "T" is positioned too far to the left. +vertical stem in the glyph "T" is positioned too far to the left at +PPEM sizes of 12. The remedy for this is to replace the instruction code with automatically generated code from the FreeType project's "ttfautohint" diff --git a/src/sfnt.c b/src/sfnt.c index 0666bb17cf0..f4c023f35c6 100644 --- a/src/sfnt.c +++ b/src/sfnt.c @@ -5474,8 +5474,6 @@ be as well. */ next = next->next; xfree (last); } - -#undef ONE_PIXEL } /* Apply winding rule to the coverage value VALUE. Convert VALUE to a commit fccaeabc959f5403ce49744030bd2620352b59f8 Author: Harald Jörg Date: Tue Jan 9 18:46:41 2024 +0100 ; cperl-mode-tests.el: Adapt to recent changes in cperl-mode.el The tests need to use the new command cperl-file-style to make sure that settings don't bleed out to following tests. * test/lisp/progmodes/cperl-mode-tests.el (cperl-test-indent-styles, cperl-test-bug-35925) (cperl-test-bug-64364, cperl-test-bug-65834): use cperl-file-style instead of cperl-set-style diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el index e3026dbfb5a..62b7fdab7f7 100644 --- a/test/lisp/progmodes/cperl-mode-tests.el +++ b/test/lisp/progmodes/cperl-mode-tests.el @@ -111,9 +111,8 @@ end of the statement." (skip-unless (eq cperl-test-mode #'cperl-mode)) (cperl--run-test-cases (ert-resource-file "cperl-indent-styles.pl") - (cperl-set-style "PBP") - (indent-region (point-min) (point-max)) ; here we go! - (cperl-set-style-back))) + (cperl-file-style "PBP") + (indent-region (point-min) (point-max)))) ; here we go! ;;; Fontification tests @@ -1145,17 +1144,16 @@ Perl is not Lisp: An open paren in column 0 does not start a function." (ert-deftest cperl-test-bug-35925 () "Check that indentation is correct after a terminating format declaration." - (cperl-set-style "PBP") ; Make cperl-mode use the same settings as perl-mode. (cperl--run-test-cases (ert-resource-file "cperl-bug-35925.pl") + (cperl-file-style "PBP") ; Make cperl-mode use the same settings as perl-mode. (let ((tab-function (if (equal cperl-test-mode 'perl-mode) #'indent-for-tab-command #'cperl-indent-command))) (goto-char (point-max)) (forward-line -2) - (funcall tab-function))) - (cperl-set-style-back)) + (funcall tab-function)))) (ert-deftest cperl-test-bug-37127 () "Verify that closing a paren in a regex goes without a message. @@ -1363,12 +1361,13 @@ as a regex." (ert-deftest cperl-test-bug-64364 () "Check that multi-line subroutine declarations indent correctly." - (cperl-set-style "PBP") ; make cperl-mode use the same settings as perl-mode (cperl--run-test-cases (ert-resource-file "cperl-bug-64364.pl") + (cperl-file-style "PBP") ; make cperl-mode use the same settings as perl-mode (indent-region (point-min) (point-max))) (cperl--run-test-cases (ert-resource-file "cperl-bug-64364.pl") + (cperl-file-style "PBP") ; make cperl-mode use the same settings as perl-mode (let ((tab-function (if (equal cperl-test-mode 'perl-mode) #'indent-for-tab-command @@ -1376,8 +1375,7 @@ as a regex." (goto-char (point-min)) (while (null (eobp)) (funcall tab-function) - (forward-line 1)))) - (cperl-set-style-back)) + (forward-line 1))))) (ert-deftest cperl-test-bug-65834 () "Verify that CPerl mode identifies a left-shift operator. commit aff1d53cd466b64ded08d5cf12f83e5746704c07 Author: Juri Linkov Date: Tue Jan 9 19:57:50 2024 +0200 Support more metadata properties in completion-extra-properties (bug#68214) * doc/lispref/minibuf.texi (Completion Variables): Add to the table of completion-extra-properties new items: `group-function', `display-sort-function', `cycle-sort-function'. * lisp/icomplete.el (icomplete--augment): Remove unnecessary plist-get from completion-extra-properties since now completion-metadata-get does this. * lisp/minibuffer.el (completion-metadata-get): Use plist-get to get prop from completion-extra-properties and cache the keyword. Thanks to Daniel Mendler . (completion-extra-properties): Mention new properties in docstring. (minibuffer-completion-help): Remove unnecessary plist-get from completion-extra-properties since now completion-metadata-get does this. * lisp/net/eww.el (eww-switch-to-buffer): * test/lisp/minibuffer-tests.el (completions-affixation-navigation-test): Unquote lambda in completion-extra-properties. diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 8d25a53161e..18df44256a8 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -1928,6 +1928,15 @@ element of the returned list must be a three-element list, the completion, a prefix string, and a suffix string. This function takes priority over @code{:annotation-function}. +@item :group-function +The function to group completions. + +@item :display-sort-function +The function to sort entries in the @file{*Completions*} buffer. + +@item :cycle-sort-function +The function to sort entries when cycling. + @item :exit-function The value should be a function to run after performing completion. The function should accept two arguments, @var{string} and diff --git a/etc/NEWS b/etc/NEWS index f4d008ee2d6..fcec2ca715a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -752,6 +752,11 @@ The new supported completion properties are 'cycle-sort-function', 'completion-category-overrides' that will override the properties defined in completion metadata. ++++ +*** 'completion-extra-properties' supports more metadata. +The new supported completion properties are 'group-function', +'display-sort-function', 'cycle-sort-function'. + ** Pcomplete --- diff --git a/lisp/icomplete.el b/lisp/icomplete.el index d49714f3204..aa3c5680a7e 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -789,10 +789,8 @@ and SUFFIX, if non-nil, are obtained from `affixation-function' or `group-function'. Consecutive `equal' sections are avoided. COMP is the element in PROSPECTS or a transformation also given by `group-function''s second \"transformation\" protocol." - (let* ((aff-fun (or (completion-metadata-get md 'affixation-function) - (plist-get completion-extra-properties :affixation-function))) - (ann-fun (or (completion-metadata-get md 'annotation-function) - (plist-get completion-extra-properties :annotation-function))) + (let* ((aff-fun (completion-metadata-get md 'affixation-function)) + (ann-fun (completion-metadata-get md 'annotation-function)) (grp-fun (and completions-group (completion-metadata-get md 'group-function))) (annotated diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 04b36f03d11..42d04e0ff96 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -151,15 +151,25 @@ The metadata of a completion table should be constant between two boundaries." minibuffer-completion-predicate)) (defun completion-metadata-get (metadata prop) - "Get PROP from completion METADATA. + "Get property PROP from completion METADATA. If the metadata specifies a completion category, the variables `completion-category-overrides' and -`completion-category-defaults' take precedence." +`completion-category-defaults' take precedence for +category-specific overrides. If the completion metadata does not +specify the property, the `completion-extra-properties' plist is +consulted. Note that the keys of the +`completion-extra-properties' plist are keyword symbols, not +plain symbols." (if-let (((not (eq prop 'category))) (cat (alist-get 'category metadata)) (over (completion--category-override cat prop))) (cdr over) - (alist-get prop metadata))) + (or (alist-get prop metadata) + (plist-get completion-extra-properties + ;; Cache the keyword + (or (get prop 'completion-extra-properties--keyword) + (put prop 'completion-extra-properties--keyword + (intern (concat ":" (symbol-name prop))))))))) (defun complete-with-action (action collection string predicate) "Perform completion according to ACTION. @@ -2447,6 +2457,15 @@ These include: `:annotation-function' when both are provided, so only this function is used. +`:group-function': Function for grouping the completion candidates. + +`:display-sort-function': Function to sort entries in *Completions*. + +`:cycle-sort-function': Function to sort entries when cycling. + +See more information about these functions above +in `completion-metadata'. + `:exit-function': Function to run after completion is performed. The function must accept two arguments, STRING and STATUS. @@ -2569,12 +2588,8 @@ The candidate will still be chosen by `choose-completion' unless base-size md minibuffer-completion-table minibuffer-completion-predicate)) - (ann-fun (or (completion-metadata-get all-md 'annotation-function) - (plist-get completion-extra-properties - :annotation-function))) - (aff-fun (or (completion-metadata-get all-md 'affixation-function) - (plist-get completion-extra-properties - :affixation-function))) + (ann-fun (completion-metadata-get all-md 'annotation-function)) + (aff-fun (completion-metadata-get all-md 'affixation-function)) (sort-fun (completion-metadata-get all-md 'display-sort-function)) (group-fun (completion-metadata-get all-md 'group-function)) (mainbuf (current-buffer)) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 22f07cbc5b4..6c46ef0fedb 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -2064,9 +2064,10 @@ If CHARSET is nil then use UTF-8." "Prompt for an EWW buffer to display in the selected window." (interactive nil eww-mode) (let ((completion-extra-properties - '(:annotation-function (lambda (buf) - (with-current-buffer buf - (format " %s" (eww-current-url)))))) + `(:annotation-function + ,(lambda (buf) + (with-current-buffer buf + (format " %s" (eww-current-url)))))) (curbuf (current-buffer))) (pop-to-buffer-same-window (read-buffer "Switch to EWW buffer: " diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 6dc15d0801f..c1fe3032cb5 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -505,11 +505,11 @@ (ert-deftest completions-affixation-navigation-test () (let ((completion-extra-properties - '(:affixation-function - (lambda (completions) - (mapcar (lambda (c) - (list c "prefix " " suffix")) - completions))))) + `(:affixation-function + ,(lambda (completions) + (mapcar (lambda (c) + (list c "prefix " " suffix")) + completions))))) (completing-read-with-minibuffer-setup '("aa" "ab" "ac") (insert "a") commit 29e59b835c86e1ebac12adcb28ab7e1d0c275b2f Author: Juri Linkov Date: Tue Jan 9 19:22:40 2024 +0200 * lisp/tab-bar.el: Fixes for point in window configuration (bug#68235) (tab-bar--tab): Instead of 'point-marker', use 'copy-marker' with the TYPE argument set to 'window-point-insertion-type'. This will allow point to follow the output after switching tabs when point is at the end of a comint/compilation buffer. (tab-bar-select-tab): Remove ad-hoc rule for the reverted dired buffer. diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 219f42848ef..3e1d8278b04 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1302,7 +1302,7 @@ tab bar might wrap to the second line when it shouldn't.") (ws . ,(window-state-get (frame-root-window (or frame (selected-frame))) 'writable)) (wc . ,(current-window-configuration)) - (wc-point . ,(point-marker)) + (wc-point . ,(copy-marker (window-point) window-point-insertion-type)) (wc-bl . ,bl) (wc-bbl . ,bbl) ,@(when tab-bar-history-mode @@ -1455,13 +1455,7 @@ Negative TAB-NUMBER counts tabs from the end of the tab bar." ;; set-window-configuration does not restore the value of ;; point in the current buffer, so restore it separately. (when (and (markerp wc-point) - (marker-buffer wc-point) - ;; FIXME: After dired-revert, marker relocates to 1. - ;; window-configuration restores point to global point - ;; in this dired buffer, not to its window point, - ;; but this is slightly better than 1. - ;; Maybe better to save dired-filename in each window? - (not (eq 1 (marker-position wc-point)))) + (marker-buffer wc-point)) (goto-char wc-point)) (when wc-bl (set-frame-parameter nil 'buffer-list wc-bl)) commit 0a5ebd444a820308571a659005d094b2dd93fe3f Author: Harald Jörg Date: Tue Jan 9 11:44:43 2024 +0100 ; cperl-mode: Fix a compiler warning caused by my previous commit * lisp/progmodes/cperl-mode.el (cperl-file-style): Replace 'make-variable-buffer-local' with 'make.local-variable' diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 5e435f7133e..bfc1742610c 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -6556,10 +6556,8 @@ and \"Whitesmith\"." (dolist (setting (cdr (assoc style cperl-style-alist)) style) (let ((option (car setting)) (value (cdr setting))) - (make-variable-buffer-local option) - (set option value))) - (make-variable-buffer-local 'cperl-file-style) - (setq cperl-file-style style)) + (set (make-local-variable option) value))) + (set (make-local-variable 'cperl-file-style) style)) (declare-function Info-find-node "info" (filename nodename &optional no-going-back strict-case