Dynamic validation of styles in completion-category-overrides
The type of the defcustom completion-category-overrides must be able
to accommodate dynamic changes to completion-styles-alist, because
some packages (eglot) make their own additions.
This change fixes a failure in test-custom-opts. See discussion at:
https://lists.gnu.org/archive/html/emacs-devel/2022-10/msg01969.html
* lisp/minibuffer.el (completion--styles-type):
Add an "Other" case that accepts any symbol which is then validated
dynamically against completion-styles-alist.
Dmitry Gutov [Tue, 25 Oct 2022 21:09:01 +0000 (00:09 +0300)]
vc-hg-checkin-patch: Add implementation for Hg
* lisp/vc/vc-hg.el (vc-hg-checkin-patch): Add Hg-specific
implementation (bug#52349), like suggested in
https://lists.gnu.org/archive/html/emacs-devel/2022-10/msg01533.html.
(vc-hg--extract-headers): Extract from vc-hg-checkin.
where the foo/bar/... bindings are not only useless but can prevent
the GC from collecting that memory (i.e. it's a representation that is
not "safe for space") and it can also make that closure "unwritable"
(or more specifically, it can cause the closure's print
representation to be u`read`able).
Compiled closures don't suffer from this problem because `cconv.el`
actually looks at the code and only stores in the compiled closure
those variables which are actually used.
So, we fix this discrepancy by letting the existing code in `cconv.el` tell
`Ffunction` which variables are actually used by the body of the
function such that it can filter out the irrelevant elements and
return a closure of the form:
(closure ((y 7)) (x) (+ x y))
* lisp/loadup.el: Preload `cconv` and set
`internal-filter-closure-env-function` once we have a usable `cconv-fv`.
* lisp/emacs-lisp/bytecomp.el (byte-compile-preprocess): Adjust to new
calling convention of `cconv-closure-convert`.
(byte-compile-not-lexical-var-p): Delete function, moved to `cconv.el`.
(byte-compile-bind): Use `cconv--not-lexical-var-p`.
* lisp/emacs-lisp/cconv.el (cconv--dynbound-variables): New var.
(cconv-closure-convert): New arg `dynbound-vars`
(cconv--warn-unused-msg): Remove special case for `ignored`,
so we don't get confused when a function uses an argument called
`ignored`, e.g. holding a list of things that it should ignore.
(cconv--not-lexical-var-p): New function, moved from `bytecomp.el`.
Don't special case keywords and `nil` and `t` since they are already
`special-variable-p`.
(cconv--analyze-function): Use `cconv--not-lexical-var-p`.
(cconv--dynbindings): New dynbound var.
(cconv-analyze-form): Use `cconv--not-lexical-var-p`.
Remember in `cconv--dynbindings` the vars for which we used
dynamic scoping.
(cconv-analyze-form): Use `cconv--dynbound-variables` rather than
`byte-compile-bound-variables`.
(cconv-fv): New function.
* src/eval.c (Fsetq, eval_sub): Remove optimization designed when
`lexical-binding == nil` was the common case.
(Ffunction): Use `internal-filter-closure-env-function` when available.
(eval_sub, Ffuncall): Improve error info for `excessive_lisp_nesting`.
(internal-filter-closure-env-function): New defvar.
Robert Pluim [Tue, 25 Oct 2022 13:18:51 +0000 (15:18 +0200)]
Fix eglot defcustom types
* lisp/progmodes/eglot.el (eglot-autoreconnect): Allow for 'nil'.
(eglot-connect-timeout): Allow for 'nil' and add descriptions.
(eglot-sync-connect): Split boolean into 'nil' and 't' and add descriptions.
(eglot-confirm-server-initiated-edits): Change 'symbol' type to 'const'.
Alan Mackenzie [Tue, 25 Oct 2022 13:28:57 +0000 (13:28 +0000)]
Test face name variables are bound before using them in cc-fonts.el
This fixes bug #58641.
Also, set c-reference-face-name to font-lock-constant face in preference to
c-label-face-name.
* lisp/progmodes/cc-fonts.el (c-preprocessor-face-name, c-label-face-name)
(c-constant-face-name, c-reference-face-name): Test variables with the same
name as font-lock faces are bound before accessing their values.
(c-reference-face-name): Use font-lock-constant face in preference to
c-label-face-name.
This removes the HAVE_PDUMPER || HAVE_UNEXEC condition
of gflags.will_dump_, which gets in the way when Emacs
is built without any dumping method. (Bug#58708)
Brian Leung [Tue, 25 Oct 2022 03:43:50 +0000 (20:43 -0700)]
eglot-server-programs: Account for new js-json-mode
js-json-mode derives from js-mode, so this reordering is necessary to
prevent js-mode's eglot server from starting if a user has something
like this in their config:
* lisp/progmodes/eglot.el (eglot-server-programs): Move the
json-language-server info before the entry for js-mode, and add on
js-json-mode. (Bug#58769)
Eli Zaretskii [Mon, 24 Oct 2022 13:43:47 +0000 (16:43 +0300)]
Unbreak the build broken by tab-bar.el changes
Without this change, compiling tab-bar.el errors out:
In tab-bar--load-buttons:
tab-bar.el:161:18: Warning: reference to free variable `tab-bar-new'
tab-bar.el:174:6: Error: `define-icon' defined after use in
(define-icon tab-bar-close nil (cons (cons 'image
(cons "tabs/close.xpm"
(cons :margin (cons tab-bar-button-margin '(:ascent center)))))
'((text " x"))) "Icon for closing the clicked tab."
:version "29.1" :help-echo "Click to close tab")
(missing `require' of a library file?)
tab-bar.el:174:18: Warning: reference to free variable `tab-bar-close'
* lisp/tab-bar.el (eval-when-compile): Require 'icons.
Fix regexp matching with atomic strings and optimised backtracking
This bug occurs when an atomic pattern is matched at the end of
a string and the on-failure-keep-string-jump optimisation is
in effect, as in:
(string-match "\\'\\(?:ab\\)*\\'" "a")
which succeeded but clearly should not (bug#58726).
Reported by Michael Heerdegen.
* src/regex-emacs.c (PREFETCH): Add reset parameter.
(re_match_2_internal): Use it for proper atomic pattern treatment.
* test/src/regex-emacs-tests.el (regexp-atomic-failure): New test.
Juri Linkov [Mon, 24 Oct 2022 07:33:41 +0000 (10:33 +0300)]
* lisp/tab-bar.el: Use customizable button icons (bug#51309, bug#51648)
* lisp/tab-bar.el (tab-bar--load-buttons): Use 'define-icon' to
define icons for tab-bar-new, tab-bar-close, tab-bar-menu-bar.
Also set tab-bar-new-button, tab-bar-close-button, tab-bar-menu-bar-button
to the specified icon-string.
(tab-bar-history-mode): Use 'define-icon' to
define icons for tab-bar-back, tab-bar-forward.
Also set tab-bar-back-button, tab-bar-forward-button
to the specified icon-string.
* lisp/emacs-lisp/icons.el (icons--create)<image>: Allow to easy
add new image props by using 'apply' on them. Add :margin.
Juri Linkov [Sun, 23 Oct 2022 16:54:31 +0000 (19:54 +0300)]
* lisp/outline.el: Pre-compute some frequent data for button icons (bug#57813)
(outline--button-icons): New buffer-local variable.
(outline-minor-mode): Set outline--button-icons.
Unify overlay name 'outline-margin' with 'outline-button'.
(outline--make-button-overlay, outline--make-margin-overlay)
(outline--insert-open-button, outline--insert-close-button): Remove functions.
(outline--create-button-icons, outline--insert-button): New functions
with code refactored from old functions. Add more support for icon faces.
(outline--fix-up-all-buttons): Use outline--insert-button.
(outline--fix-buttons-after-change): Unify overlay name
'outline-margin' with 'outline-button'.
* lisp/minibuffer.el (completions-group-separator): Change face
attribute :strike-through to :underline.
Po Lu [Sun, 23 Oct 2022 06:12:02 +0000 (14:12 +0800)]
Reduce duplicate code for creating "special windows"
* src/xterm.c (x_create_special_window): Define on all non-GTK
builds and all builds with XFixes.
(x_update_frame_user_time_window): Use x_create_special_window.
Also write a comment explaining what user time windows are.
* src/xterm.h: Fix style of `x_parse_color' prototype.
* lisp/net/eudc.el (eudc--plist-member): Signal a more
informative wrong-type-argument instead of a generic error
(bug#58531#19, bug#58720).
* test/lisp/net/eudc-tests.el (eudc--plist-member)
(eudc-plist-member, eudc-plist-get, eudc-lax-plist-get):
Update tests accordingly.
Juri Linkov [Sat, 22 Oct 2022 18:57:40 +0000 (21:57 +0300)]
* lisp/outline.el: Use 'outline-cycle' on buttons for 'RET' like 'TAB' uses.
(outline--make-button-overlay, outline--make-margin-overlay):
Use overlay keymap where RET and mouse-2 are bound to outline-cycle.
(outline--insert-open-button, outline--insert-close-button):
Move overlay keymap to outline--make-button-overlay and replace
bindings outline-hide-subtree/outline-show-subtree with outline-cycle.
Juri Linkov [Sat, 22 Oct 2022 18:37:56 +0000 (21:37 +0300)]
Unify outline-minor-mode-use-buttons with in-margins/insert values (bug#57813)
* doc/emacs/text.texi (Outline Mode): Remove outline-minor-mode-use-margins.
Document the values insert/in-margins of outline-minor-mode-use-buttons.
* lisp/help.el (describe-bindings):
Set outline-minor-mode-use-buttons to 'insert'.
* lisp/textmodes/emacs-news-mode.el (emacs-news--mode-common):
Set outline-minor-mode-use-buttons to 'in-margins'.
* lisp/outline.el (outline-minor-mode-use-buttons): Change :type
from 'buffer-predicate' to choice of const values nil/in-margins/t.
(outline--use-buttons, outline-minor-mode-insert-buttons)
(outline-minor-mode-use-margins, outline--use-margins): Remove variables.
(outline-minor-mode-highlight-buffer): Change overlay name
'outline-overlay' to 'outline-highlight'.
(outline-minor-mode): Simplify to handle possible values of
'outline-minor-mode-use-buttons' instead of using many variables.
(outline--make-button-overlay): Use value 'insert' of
'outline-minor-mode-use-buttons'.
(outline--insert-open-button, outline--insert-close-button)
(outline--fix-up-all-buttons, outline--fix-buttons-after-change):
Handle values of outline-minor-mode-use-buttons instead of using
many variables.
* doc/lispref/lists.texi (Plist Access): Improve description of
default predicate.
* lisp/emacs-lisp/cl-extra.el (cl-getf, cl--set-getf): Assume
plist-member always returns a cons.
* lisp/emacs-lisp/gv.el (plist-get): Support new optional predicate
argument (bug#47425#91).
* lisp/emacs-lisp/map.el: Bump minor version.
(map--dispatch): Remove now that bug#58563 is fixed. Break two
remaining uses out into corresponding cl-defmethods.
(map--plist-p): Add docstring.
(map--plist-has-predicate, map--plist-member-1, map--plist-member)
(map--plist-put-1, map--plist-put): New definitions for supporting
predicate argument backward compatibly.
(map-elt): Fix generalized variable getter under a
predicate (bug#58531). Use predicate when given a plist.
(map-put): Avoid gratuitous warnings when called without the hidden
predicate argument. Improve obsoletion message.
(map-put!): Use predicate when given a plist.
(map-contains-key): Ditto. Declare forgotten
advertised-calling-convention (bug#58531#19).
(map--put): Group definition in file together with that of map-put!.
* lisp/files-x.el (connection-local-normalize-criteria): Simplify
using mapcan + plist-get.
* lisp/net/eudc.el (eudc--plist-member): New convenience function.
(eudc-plist-member, eudc-plist-get, eudc-lax-plist-get): Use it
instead of open-coding plist-member.
* src/fns.c (Fplist_get, plist_get, Fplist_put, plist_put): Pass the
plist element as the first argument to the predicate, for
consistency with assoc + alist-get.
(Fplist_member, plist_member): Move from widget to plist section.
Open-code the EQ case in plist_member, and call it from
Fplist_member in that case, rather than the other way around.
* test/lisp/apropos-tests.el (apropos-tests-format-plist): Avoid
polluting obarray.
* test/lisp/emacs-lisp/cl-extra-tests.el (cl-getf): Extend test with
generalized variables, degenerate plists, and improper lists.
* test/lisp/emacs-lisp/gv-tests.el: Byte-compile file; in the
meantime bug#24402 seems to have been fixed or worked around.
(gv-setter-edebug): Inhibit printing messages.
(gv-plist-get): Avoid modifying constant literals. Also test with a
predicate argument.
* test/lisp/emacs-lisp/map-tests.el (with-maps-do): Simplify
docstring.
(test-map-elt-testfn): Rename...
(test-map-elt-testfn-alist): ...to this. Also test with a predicate
argument.
(test-map-elt-testfn-plist, test-map-elt-gv, test-map-elt-signature)
(test-map-put!-plist, test-map-put!-signature)
(test-map-contains-key-signature, test-map-plist-member)
(test-map-plist-put): New tests.
(test-map-contains-key-testfn): Also test with a predicate argument.
(test-map-setf-alist-overwrite-key, test-map-setf-plist-insert-key)
(test-map-setf-plist-overwrite-key): Avoid modifying constant
literals.
(test-hash-table-setf-insert-key)
(test-hash-table-setf-overwrite-key): Fix indentation.
(test-setf-map-with-function): Make test more precise.
* test/lisp/net/eudc-tests.el: New file.
* test/lisp/subr-tests.el (test-plistp): Extend test with circular
list.
* test/src/fns-tests.el (test-cycle-equal, test-cycle-nconc): Move
from plist section to circular list section.
(plist-put/odd-number-of-elements): Avoid modifying constant
literals.
(plist-member/improper-list): Simplify.
(test-plist): Move to plist section. Also test with a predicate
argument.
Po Lu [Sat, 22 Oct 2022 12:15:22 +0000 (20:15 +0800)]
Further fixes to menu event processing on no-toolkit builds
* src/xdisp.c (note_mouse_highlight): Return if a popup is
activated under the no-toolkit build as well.
* src/xmenu.c (pop_down_menu): Clear popup_activated_flag when
not on MS-DOS.
(x_menu_show): Set popup_activated_flag under X.
Po Lu [Fri, 21 Oct 2022 13:31:54 +0000 (21:31 +0800)]
Fix various menu problems
* src/menu.c (x_popup_menu_1): Cancel hourglass timer before
displaying popup.
* src/xterm.c (x_show_hourglass): Avoid displaying hourglass
cursor during a popup.
(handle_one_xevent): Under X Toolkit and GTK+ 2.x builds with
XInput 2, clear the mouse face upon a core LeaveNotify; these
can be generated by menu grabs.
(x_wm_set_size_hint): Fix Motif build warning.
* doc/emacs/emacs.texi (Top):
* doc/emacs/programs.texi (Documentation, Programming Language Doc):
Rename "Lisp Doc" to "Programming Language Doc", including in
parent menus. All references changed.
(Programming Language Doc): Formerly "Lisp Doc". Rewrite to not
be specific to Emacs Lisp. Improve markup and wording. Document
more commands and variables.
* doc/emacs/maintaining.texi (Maintaining): Improve indexing.
Po Lu [Fri, 21 Oct 2022 11:19:33 +0000 (19:19 +0800)]
Fix delivery of window manager ping events during menu
* oldXMenu/Activate.c (XMenuActivateSetExposeFunction)
(XMenuActivate):
* oldXMenu/XMenu.h: Remove expose functions.
* src/msdos.h (XMenuSetAEQ): Remove no longer used function.
* src/xmenu.c (x_menu_expose_event): Delete function.
(x_menu_dispatch_event): New function.
(x_menu_show): Set it as the XMenu event handler.
Brian Leung [Fri, 21 Oct 2022 05:47:10 +0000 (22:47 -0700)]
Add the "nil" language server to eglot-server-programs
* lisp/progmodes/eglot.el (eglot-server-programs): Add the "nil"
language server. Put it before rnix-lsp since it is more featureful
and more actively updated. (Bug#58676)
Ref: https://github.com/oxalica/nil
Brian Leung [Fri, 21 Oct 2022 05:49:08 +0000 (22:49 -0700)]
Add lua-language-server to eglot-server-programs
* lisp/progmodes/eglot.el (eglot-server-programs): Add
lua-language-server. It is, at the time of writing, more actively
developed and more popular than the lua-lsp server, so prioritize
that. (Bug#58676)
João Távora [Thu, 20 Oct 2022 10:42:25 +0000 (11:42 +0100)]
Revert "eglot.texi: Make example more realistic"
This quest for realism ignores the fact that a previous example for a
hypothetical language Foo and a language server "fools" already
exists. It also undermines the intended generality of the
instructions.
João Távora [Thu, 20 Oct 2022 10:20:30 +0000 (11:20 +0100)]
Fix Eglot manual's description of eglot-workspace-configuration
* doc/misc/eglot.texi (Customizing Eglot)
(eglot-workspace-configuration): Explain that plist may be
arbitrarily complex and correctly identify nil as the Elisp
equivalent to JSON null.
Mauro Aranda [Thu, 20 Oct 2022 10:34:38 +0000 (07:34 -0300)]
Improve HERE document detection in perl-mode
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function):
Detect indented HERE documents when using a bare identifier.
(perl--syntax-exp-intro-keywords): Recognize HERE documents that come
after die, warn and eval.
(perl--syntax-exp-intro-regexp): Identify HERE documents when printing
to a filehandle with printf? and when they appear after a fat comma.
* test/lisp/progmodes/cperl-mode-resources/here-docs.pl: Add more tests.
Eli Zaretskii [Thu, 20 Oct 2022 05:59:18 +0000 (08:59 +0300)]
; Remove reference to non-existent Flymake function from manual
* doc/emacs/building.texi (Flymake): Replace reference to a delete
command 'flymake-display-err-menu-for-current-line' with existing
equivalents. (Bug#58649)
Alan Mackenzie [Wed, 19 Oct 2022 14:52:14 +0000 (14:52 +0000)]
CC Mode: Cease adding types to found-types too eagerly
This fixes bug #58537 and bug #58539.
* lisp/progmodes/cc-engine.el (c-forward-type): Remove trailing whitespace
from an identifier before passing it to c-add-type.
(c-forward-decl-or-cast-1): CASE 3: Do not recognize two consecutive
identifiers as type + variable/function unless certain conditions are met.
CASE 10: Do not recognize the "type" as a found type unless certain condtions
are met. (Near end): Do not recognize the identifier in a cast as a type
unless certain conditions are met.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context): Recognize being
in declaration parens when there is a syntactially wrong "foo ((bar))"
preceding the match position.
* lisp/progmodes/cc-mode.el (c-update-new-id): Set c-new-id-is-type
unconditionally to nil to prevent a second identifier being wrongly marked as
a type.
Po Lu [Wed, 19 Oct 2022 13:31:54 +0000 (21:31 +0800)]
Fix various builds
* src/xterm.c (x_handle_selection_monitor_event): Adjust for
build without XInput2.
(x_maybe_clear_preedit, xim_destroy_callback): Make conditional
on Release 6 XIM.
(x_get_keyboard_modifiers): Adjust for build without XCB.