Stefan Monnier [Sun, 12 Nov 2023 16:37:38 +0000 (11:37 -0500)]
(derived-mode-all-parents): Fix handling of cycles
* lisp/subr.el (derived-mode-all-parents): Fix the handling of cycles
so that it doesn't fill the cache with incorrect results.
(merge-ordered-lists): Improve docstring.
(provided-mode-derived-p): Swap the loops since `modes` is usually
shorter than `ps`.
* test/lisp/subr-tests.el (subr-tests--parent-mode): Simplify.
(subr-tests--mode-A, subr-tests--mode-B, subr-tests--mode-C): New funs.
(subt-tests--derived-mode-add-parents): New test.
Stefan Monnier [Tue, 7 Nov 2023 23:57:03 +0000 (18:57 -0500)]
Move EIEIO's C3 linearization code to `subr.el`
The code was used to linearize the EIEIO class hierarchy, since
it results in saner results than things like BFS or DFS.
By moving it to `subr.el` we get to benefit from that same
advantage both in `cl--class-allparents` and
in `derived-mode-all-parents`.
* lisp/subr.el (merge-ordered-lists): New function.
(derived-mode-all-parents): Use it to improve parent ordering.
* lisp/emacs-lisp/eieio-core.el (eieio--c3-candidate)
(eieio--c3-merge-lists): Delete functions, replaced by
`merge-ordered-lists`.
(eieio--class-precedence-c3): Use `merge-ordered-lists`.
* lisp/emacs-lisp/cl-preloaded.el (cl--class-allparents):
Use `merge-ordered-lists` to improve parent ordering.
* lisp/emacs-lisp/cl-macs.el (cl--struct-all-parents): Delete function.
(cl--pcase-mutually-exclusive-p): Use `cl--class-allparents` instead.
Stefan Monnier [Tue, 7 Nov 2023 00:05:40 +0000 (19:05 -0500)]
Use `derived-mode-add-parents` in remaining uses of `derived-mode-parent`
Until now multiple inheritance wasn't really used, but some ad-hoc
code went a bit beyond the normal uses of the mode hierarchy.
Use the new multiple inheritance code to replace that ad-hoc code,
thereby eliminating basically all remaining direct uses of the
`derived-mode-parent` property.
CEDET had its own notion of mode hierrchy using `derived-mode-parent`
as well as its own `mode-local-parent` property set via
`define-child-mode`.
`derived-mode-add-parents` lets us reimplement `define-child-mode`
such that CEDET can now use the normal API functions.
* lisp/locate.el (locate-mode): Use `derived-mode-add-parents`.
* lisp/cedet/mode-local.el (get-mode-local-parent): Declare obsolete.
(mode-local-equivalent-mode-p, mode-local-use-bindings-p): Make them
obsolete aliases.
(mode-local--set-parent): Rewrite to use `derived-mode-add-parents`.
Declare as obsolete.
(mode-local-map-mode-buffers): Use `derived-mode-p`.
(mode-local-symbol, mode-local--activate-bindings)
(mode-local--deactivate-bindings, mode-local-describe-bindings-2):
Use `derived-mode-all-parents`.
* lisp/cedet/srecode/table.el (srecode-get-mode-table):
* lisp/cedet/srecode/find.el (srecode-table, srecode-load-tables-for-mode)
(srecode-all-template-hash): Use `derived-mode-all-parents`.
* lisp/cedet/srecode/map.el (srecode-map-entries-for-mode):
* lisp/cedet/semantic/db.el (semanticdb-equivalent-mode):
Use `provided-mode-derived-p` now that it obeys `define-child-mode`.
Stefan Monnier [Wed, 8 Nov 2023 19:20:09 +0000 (14:20 -0500)]
(derived-mode-all-parents): Speed up with a cache
Most uses of the mode hierarchy don't really need to construct the
list, they just need to iterate over it. With single inheritance
we could do it just by jumping up from a mode to its parent,
but to support the upcoming multiple inheritance we'd need a more
complex and costly iterator.
Luckily, the inheritance graph is mostly static so we can cache
the list of all parents, making `derived-mode-all-parents` cheap
enough to be the basis of iteration and keeping the API very simple.
* lisp/subr.el (derived-mode-all-parents): Cache the result.
(derived-mode--flush): New function.
(derived-mode-set-parent): Use it.
Stefan Monnier [Wed, 8 Nov 2023 16:32:27 +0000 (11:32 -0500)]
subr.el: Provide a functional API around `derived-mode-parent`
The `derived-mode-parent` property should be an implementation detail,
so we can change it more easily. To that end, add functions to set and
query it.
* lisp/subr.el (derived-mode-all-parents): New function.
(provided-mode-derived-p): Use it.
(derived-mode-set-parent): New function.
Alan Mackenzie [Wed, 8 Nov 2023 20:49:48 +0000 (20:49 +0000)]
With `native-compile', compile lambdas in a defun or lambda too
This fixes bug#64646. Also refactor two functions to reduce
code duplication.
* lisp/emacs-lisp/comp.el (comp-spill-lap-function/symbol)
(comp-spill-lap-function/list): Add all functions found by the
byte compiler (including lambdas) to the native compiler's
context, thus making them be native compiled. Refactor to use
comp-intern-func-in-ctxt. Make comp-spill-lap-function/list
also compile closures.
* test/src/comp-resources/comp-test-funcs.el
(comp-tests-lambda-return-f2): New function
* test/src/comp-tests.el (comp-test-lambda-return2)
(comp-tests-free-fun-f2): New functions to test that internal
lambdas get native compiled.
* lisp/progmodes/project.el (project-remember-projects-under): Instead
of traversing the directories manually, re-use
`directory-files-recursively' to reduce complexity. (Bug#66649)
Po Lu [Wed, 8 Nov 2023 03:03:57 +0000 (11:03 +0800)]
Don't leave point amid text conversion edits if auto-fill transpires
* lisp/simple.el (analyze-text-conversion): Save point in
old-point after auto-fill completes, so that point-moved is not
set if point remains intact subsequent to the execution of both
hooks.
João Távora [Wed, 25 Oct 2023 12:45:01 +0000 (13:45 +0100)]
Allow completion frontends to fontify candidates just-in-time
bug#48841, bug#47711
The variable may be bound by the frontend to a non-nil around
completion-producing calls like completion-all-completions. See
completion-lazy-hilit docstring for more info.
* lisp/minibuffer.el (completion-lazy-hilit): New variable.
(completion-lazy-hilit): New function.
(completion-lazy-hilit-fn): New variable.
(completion-pcm--regexp)
(completion--flex-score-last-md): New helper variables.
(completion--flex-score-1): New helper.
(completion-pcm--hilit-commonality): Use completion-lazy-hilit.
(completion--flex-adjust-metadata): Rework sorting code.
Po Lu [Mon, 6 Nov 2023 02:14:09 +0000 (10:14 +0800)]
Emulate secondary selections on Android
* doc/lispref/frames.texi (Other Selections): Revise
documentation to match.
* lisp/term/android-win.el (android-secondary-selection): New
variable.
(android-primary-selection, android-get-clipboard-1)
(android-get-primary, gui-backend-get-selection)
(gui-backend-selection-exists-p, gui-backend-selection-owner-p)
(gui-backend-set-selection): Update doc strings and code as is
proper.
Juri Linkov [Sun, 5 Nov 2023 17:52:33 +0000 (19:52 +0200)]
New option to use arrows in the minibuffer to select completions (bug#59486)
* lisp/minibuffer.el (minibuffer-visible-completions): New defcustom.
(minibuffer-visible-completions-bind): New function.
(minibuffer-visible-completions-map): New defvar-keymap.
(minibuffer-mode): Set buffer-local minibuffer-completion-auto-choose
to nil for minibuffer-visible-completions.
(completing-read-default, completion-in-region-mode):
Use minibuffer-visible-completions to compose keymap
with minibuffer-visible-completions-map.
(minibuffer-next-completion): Add new arg VERTICAL,
and use next-line-completion.
(minibuffer-next-line-completion)
(minibuffer-previous-line-completion): New commands.
Po Lu [Sun, 5 Nov 2023 02:40:52 +0000 (10:40 +0800)]
Implement more Android text editing controls
* lisp/term/android-win.el (android-deactivate-mark-command):
New command.
(select-all, start-selecting-text, stop-selecting-text): Arrange
for commands manipulating the region to be executed when these
keys are registered.
* src/android.c (android_get_keysym_name): Return the keysym
name of each of the new keysyms introduced.
* src/androidterm.c (performContextMenuAction): Save special
keysyms into key events for the selectAll, startSelectingText
and stopSelectingText actions.
Dmitry Gutov [Sun, 5 Nov 2023 00:35:25 +0000 (02:35 +0200)]
Add project-any-command and project-prefix-or-any-command
* lisp/progmodes/project.el (project-any-command): New command.
(project-prefix-map): Bind it to 'o'.
(project-switch-commands): Add entry for it here too.
(project-prefix-or-any-command): New command (bug#63648).
(project-switch-commands): Update the custom type to mention
'project-prefix-or-any-command' as well.
* etc/NEWS: Document the change.
F. Jason Park [Fri, 3 Nov 2023 00:05:48 +0000 (17:05 -0700)]
Align date stamps to whole days in ERC
* lisp/erc/erc-stamp.el (erc-stamp--current-time): Ditch overriding
precedence of the `erc--ts' property in `:around' method because the
variable `erc-stamp--current-time' fills that role well enough.
(erc-stamp--current-datestamp-left): Remove unused variable.
(erc-stamp--insert-date-stamp-as-phony-message): Assume
`erc-timestamp-last-inserted-left' has already been assigned the
updated rendered stamp for the current time.
(erc-stamp--lr-date-on-pre-modify): Use the variable
`erc-stamp--current-time' instead of the `erc-ts' property to convey
an overriding time value for `erc-add-timestamp'. Set
`erc-timestamp-last-inserted-left' instead of fiddling with another
temporary variable to hack around these ill-fitting interfaces. Use
day-aligned time value for the `erc-ts' property assigned to date
stamps.
(erc-stamp--date-mode): New internal minor mode.
(erc-insert-timestamp-left-and-right): Defer to `erc-stamp--date-mode'
for setting up date-stamp specific hooks.
(erc-stamp--time-as-day): New function to "round" a date stamp to
start of local day.
(erc-stamp--setup): Defer to `erc-stamp--date-mode' for date-stamp
specific teardown. (Bug#60936)
* test/lisp/erc/erc-fill-tests.el
(erc-fill-tests--current-time-value): Change default value to nil.
(erc-stamp--current-time): New method for test cases.
(erc-fill-tests--insert-privmsg): Use realistic value for `unparsed'
slot.
(erc-fill-tests--wrap-populate): Bind
`erc-fill-tests--current-time-value' to 0. Don't mock the function
`erc-stamp--current-time' because doing so inhibits normal polymorphic
dispatch, which test cases rely on for delivering correct timestamp
values in varied contexts.
; * test/lisp/erc/resources/fill/snapshots/merge-01-start.eld: Update.
; * test/lisp/erc/resources/fill/snapshots/merge-02-right.eld: Update.
; * test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld: Update.
F. Jason Park [Sat, 4 Nov 2023 20:48:11 +0000 (13:48 -0700)]
Decouple disparate escape-hatch concerns in erc-stamp
* lisp/erc/erc-stamp.el (erc-stamp--allow-unmanaged): Improve doc
string.
(erc-stamp--permanent-cursor-sensor-functions): New variable to take
over the formerly provided `cursor-sensor-functions' aspect of the
flag `erc-stamp--allow-unmanaged'.
(erc-add-timestamp): Use
`erc-stamp--permanent-cursor-sensor-functions' instead of
`erc-stamp--allow-unmanaged' in guard condition.
(erc-munge-invisibility-spec): Use dedicated compatibility flag
`erc-stamp--permanent-cursor-sensor-functions' and forgo unnecessary
setup when it's non-nil. (Bug#60936)
F. Jason Park [Sat, 4 Nov 2023 18:08:22 +0000 (11:08 -0700)]
Preserve user markers when inserting ERC date stamps
* lisp/erc/erc-stamp.el
(erc-stamp--insert-date-stamp-as-phony-message): Ensure existing
user markers aren't displaced by date-stamp insertion.
* lisp/erc/erc.el (erc--insert-line-function): New function-valued
variable for overriding `insert'.
(erc-insert-line): Call `erc--insert-line-function', when non-nil, to
insert line specially.
* test/lisp/erc/erc-scenarios-stamp.el
(erc-scenarios-stamp--on-insert-modify): New assertion helper
function.
(erc-scenarios-stamp--date-mode/left-and-right): New test.
(Bug#60936)
F. Jason Park [Thu, 2 Nov 2023 02:22:49 +0000 (19:22 -0700)]
Don't over-truncate erc-timestamp-format-left
* lisp/erc/erc-stamp.el (erc-timestamp-format-left): Fix typo in doc
string and mention that changing the value mid-session requires
cycling the minor mode.
(erc-echo-timestamp-format): Add Custom :tag for choices.
(erc-stamp--date-format-end): Revise doc string.
(erc-stamp--format-date-stamp): Fix bug involving erroneous truncation
parameter for `substring' when `erc-timestamp-format-left' doesn't end
in a newline. Thanks to Emanuel Berg for catching this.
(erc-stamp-prepend-date-stamps-p) Revise doc string.
(erc-insert-timestamp-left-and-right): Add comment regarding
compatibility concession. (Bug#60936)
F. Jason Park [Fri, 3 Nov 2023 23:07:20 +0000 (16:07 -0700)]
Really fix off-by-one in erc--get-inserted-msg-bounds
* lisp/erc/erc.el (erc--get-inserted-msg-bounds): Account for
`previous-single-property-change' returning a position adjacent to
that with an actual changed value. The prior attempt at addressing
this was insufficient.
* test/lisp/erc/erc-tests.el (erc--get-inserted-msg-bounds): New test.
; * test/lisp/erc/resources/base/local-modules/second.eld: Timeout.
; * test/lisp/erc/resources/base/local-modules/third.eld: Timeout.
Stefan Kangas [Sat, 4 Nov 2023 13:51:33 +0000 (14:51 +0100)]
Make FAQ on starting Emacs maximized portable
* doc/misc/efaq.texi (Start Emacs Maximized): Rename node from
"Fullscreen mode on MS-Windows". Make advice portable to other
platforms, and remove MS-Windows specific hacks.
Ref: https://lists.gnu.org/r/emacs-devel/2023-10/msg00733.html
Co-authored-by: David Hedlund <public@beloved.name>
Jens Schmidt [Wed, 1 Nov 2023 18:56:06 +0000 (19:56 +0100)]
Add tests for saving to write-protected files
* test/lisp/files-tests.el (files-tests--with-yes-or-no-p): Add macro.
(files-tests-save-buffer-read-only-file): Add test for writing to
write-protected files with `save-buffer'. (Bug#66546)
Eli Zaretskii [Sat, 4 Nov 2023 07:33:33 +0000 (09:33 +0200)]
Remove unnecessary assertion added 2 days ago
* src/xdisp.c (get_glyph_face_and_encoding): Remove unnecessary
assertion. It triggers, for no good reason, when running the
recipe of bug#66922 and typing C-p in the *Warnings* buffer after
the recipe finishes, because the glyph passed to this function is
a STRETCH_GLYPH, not a CHAR_GLYPH.
Po Lu [Fri, 3 Nov 2023 03:32:17 +0000 (11:32 +0800)]
Avoid moving point while analyzing text conversion
* lisp/simple.el (analyze-text-conversion): If neither calling
p-s-i-h nor calling p-t-c-h yields a change to point, return it
to its location before analyze-text-conversion was called.
* src/keyboard.c (kbd_buffer_get_event): See that text
conversion events are uniformly delivered prior to keyboard
events arriving in unison.
Dmitry Gutov [Thu, 2 Nov 2023 23:40:36 +0000 (01:40 +0200)]
Remove 'M-.' binding from js-mode and js-ts-mode
* lisp/progmodes/js.el (js-mode-map, js-ts-mode-map): Remove.
The global binding must be a lot more useful for most users
(https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg01295.html).
Po Lu [Thu, 2 Nov 2023 05:18:37 +0000 (13:18 +0800)]
Properly compute overhangs for overstruck text
* src/xdisp.c (get_glyph_face_and_encoding): Account for
non-character glyphs by not attempting to translate them to
characters.
(gui_get_glyph_overhangs, gui_produce_glyphs): If the face is
overstruck, increase the right side bearing by 1 pixel.
F. Jason Park [Tue, 31 Oct 2023 23:50:16 +0000 (16:50 -0700)]
Preserve point when inserting date stamps in ERC
* lisp/erc/erc-stamp.el (erc-stamp-mode, erc-stamp-disable): Move
remaining local teardown business to `erc-stamp--setup' and use
`erc-buffer-do' instead of `erc-with-all-buffers-of-server' to
emphasize that all ERC buffers are affected.
(erc-stamp--insert-date-stamp-as-phony-message): Move `erc--msg-props'
binding to `erc-stamp--lr-date-on-pre-modify'.
(erc-stamp--lr-date-on-pre-modify): Bind `erc--msg-props' here so that
the related guard condition in `erc-add-timestamp' is satisfied and
`erc-insert-timestamp-function' runs. This fixes a regression new in
ERC 5.6 and introduced by c68dc778 "Manage some text props for ERC
insertion-hook members". Also, `save-excursion' when narrowing to
prevent point from being dislodged after submitting input at the
prompt.
(erc-insert-timestamp-left-and-right): Don't initialize date stamps
when `erc-timestamp-format-left' is nil or consists only of newlines,
and enable fallback behavior in such cases on behalf of users without
informing them. Allow global hook members to run first so that those
owned by `scrolltobottom' and similar can see the unadulterated input.
Fix wrong hook name.
(erc-stamp--setup): Fix wrong hook name. Kill all local vars here
instead of sharing this duty with the minor-mode toggle. (Bug#60936)
F. Jason Park [Tue, 31 Oct 2023 06:36:54 +0000 (23:36 -0700)]
; Attempt to fix race in erc-buffer-display test
* test/lisp/erc/erc-fill-tests.el (erc-fill-tests--time-vals,
erc-fill-tests--current-time-value): Rename former to latter and
change type from function to natnum.
(erc-fill-tests--wrap-populate, erc-fill-wrap--merge,
erc-fill-wrap--merge-action): Use `erc-fill-tests--current-time-value'
instead of function `erc-fill-tests--time-vals'.
* test/lisp/erc/erc-scenarios-base-association.el
(erc-scenarios-common--base-association-multi-net): Extend timeout.
* test/lisp/erc/erc-scenarios-base-buffer-display.el
(erc-scenarios-base-buffer-display--reconnect-common): Move some
common assertions here from callers.
(erc-scenarios-base-buffer-display--defwin-recbury-intbuf,
erc-scenarios-base-buffer-display--count-reset-timeout):
Factor out a couple common assertions. Clarify some comments.
(erc-scenarios-base-buffer-display--defwino-recbury-intbuf):
Factor out a couple common assertions and clarify some comments.
Account for possible concurrency bug leading to intermittent
test failures.
* test/lisp/erc/erc-scenarios-base-misc-regressions.el
(erc-scenarios-base-gapless-connect,
erc-scenarios-base-channel-buffer-revival): Extend timeouts.
* test/lisp/erc/resources/dcc/chat/accept.eld: Extend timeout.
* test/lisp/erc/resources/base/reconnect/options-again.eld: Extend
timeouts.
* test/lisp/erc/resources/erc-d/erc-d.el (erc-d--m): Prevent possible
wrong-type error.
* test/lisp/erc/resources/erc-d/resources/dynamic-foonet.eld: Extend
timeouts.
* test/lisp/erc/resources/erc-scenarios-common.el
(erc-scenarios-common--base-network-id-bouncer): Extend timeout.
Juri Linkov [Wed, 1 Nov 2023 17:45:05 +0000 (19:45 +0200)]
New commands previous-line-completion and next-line-completion (bug#59486)
* lisp/simple.el (completion-list-mode-map): Bind [up] to
'previous-line-completion', and [down] to 'next-line-completion'.
(completion-auto-wrap): Mention `next-line-completion' and
`previous-line-completion' in the docstring.
(previous-line-completion, next-line-completion): New commands.
* etc/NEWS: Mention user option 'Man-support-remote-systems'.
Fix typos.
* lisp/dired.el (Man-support-remote-systems): Declare.
(dired-do-man): Use it. Use also `file-local-name'.
* lisp/man.el (Man-support-remote-systems): New defcustom.
(Man-xref-normal-file): Handle remote files.
(Man-default-directory, Man-shell-file-name)
(Man-header-file-path): New defuns.
(Man-init-defvars): Use octal numbers.
(Man-support-local-filenames): Handle remote files.
(Man-completion-table): Use `Man-default-directory' and `process-file'.
(man): Adapt docstring.
(Man-start-calling): Use `Man-default-directory'.
(Man-getpage-in-background): Use `Man-default-directory',
`Man-shell-file-name', `start-file-process' and `process-file'. Adapt
buffer name.
(Man-update-manpage): Use `Man-shell-file-name' and `process-file'.
(Man-view-header-file): Use `Man-header-file-path'.
Dmitry Gutov [Wed, 1 Nov 2023 02:01:53 +0000 (04:01 +0200)]
Only override the current project buffer-locally
* lisp/progmodes/project.el (project-switch-project): Only
override the current project buffer-locally. This is mostly for
the the mode-line indicator (https://debbugs.gnu.org/66317#53).
Po Lu [Tue, 31 Oct 2023 10:41:59 +0000 (18:41 +0800)]
Extract underline positions from PostScript metrics tables
* src/sfntfont.c (struct sfnt_font_desc): Introduce fields where
the font's underline position is recorded.
(sfnt_enum_font_1): Compute the underline position with
information in the post table whenever it exists.
(sfntfont_open): Scale the recorded position and save it into
the font object.
Po Lu [Mon, 30 Oct 2023 07:32:58 +0000 (15:32 +0800)]
Ascertain font spacing from post table if present
* src/sfnt.c (sfnt_table_names): Introduce name of post table.
(sfnt_read_post_table): New function.
(main): New tests.
* src/sfnt.h (struct sfnt_post_table): New struct.
* src/sfntfont.c (sfnt_enum_font_1): Read post table, and set
spacing from its is_fixed_pitch value.
(sfntfont_list_1): Compare spacing between both fonts if
supplied in the font spec.
(sfntfont_open): Set FONT_FILE_INDEX as well as
FONT_FULLNAME_INDEX.
Stefan Monnier [Mon, 30 Oct 2023 04:59:19 +0000 (00:59 -0400)]
comp-cstr.el: The type hierarchy is a DAG, not a tree
Adjust the type operations to account for the fact that types can have
several parents.
* lisp/emacs-lisp/comp-cstr.el (comp--cl-class-hierarchy):
Use `cl--class-allparents`. Add FIXME.
(comp--direct-supertype): Declare obsolete.
(comp--direct-supertypes): New function.
(comp--normalize-typeset0): Rewrite to use `comp--direct-supertypes`;
adjust to account for the DAG structure; use `cl-set-difference`.
(comp--direct-subtypes): Rewrite.
(comp--intersection): New function.
(comp-supertypes): Rewrite and change return type.
(comp-subtype-p): Simplify.
(comp-union-typesets): Use `comp-supertypes` instead of iterating over
`comp-cstr-ctxt-typeof-types`.
* lisp/emacs-lisp/comp.el (comp--native-compile): Don't catch
errors if we're debugging.
* test/lisp/emacs-lisp/comp-cstr-tests.el: Adjust tests.
* lisp/emacs-lisp/cl-macs.el (cl-defstruct): Fix mishap when we
evaluate (cl-defstruct cl-structure-object ..) during the compilation
of `cl-preloaded.el`.
* lisp/emacs-lisp/cl-preloaded.el: Add corresponding assertion.
Spencer Baugh [Sat, 21 Oct 2023 18:35:53 +0000 (14:35 -0400)]
Teach ffap to look for relative file names under project-root
Now file-name-at-point-functions, which runs
ffap-guess-file-name-at-point, will pick up on a file name at point if
that file name is a relative file name which exists when looked up
from the root of the project.
For example, in test/lisp/progmodes/eglot-tests.el there is the string
lisp/progmodes/eglot.el; if you put point on that and C-x C-f,
lisp/progmodes/eglot.el under the root of the Emacs repo will now be
part of future history.
* lisp/ffap.el (ffap-alist): Add entry for ffap-in-project.
(ffap-in-project): Add. (bug#66668)
Nested repetitions such as (A*)* potentially take exponential time but
can usually be rewritten in a faster and more readable way without
much trouble. These were all found by Relint.
* lisp/textmodes/fill.el (adaptive-fill-regexp):
Apply the transform A*(B+A*)* -> (A|B)*
* lisp/progmodes/idlw-shell.el (idlwave-shell-filter):
Find the last newline or CR in a more direct way.
* lisp/progmodes/vhdl-mode.el (vhdl-port-copy, vhdl-subprog-copy):
Trim trailing whitespace from a string in a more direct way.
All-whitespace strings are left unchanged as before.
* lisp/progmodes/gdb-mi.el (gdb-python-guile-commands-regexp):
Remove, integrate into...
(gdb-control-commands-regexp): ...this. Translate into rx.
Remove useless submatches which broke earlier attempts at using other
submatches. Rewrite tail expression to avoid superlinear nested
repetition, eliminating a Relint complaint.
* lisp/progmodes/gdb-mi.el (gdb-send): Simplify use of the regexp
above, and use the correct submatch this time. Remove unnecessary and
incorrect second regexp matching.
Passing arbitrary arguments to functions through
"emacsclient --eval" sometimes requires complicated escaping
to avoid them being parsed as Lisp (as seen in
emacsclient-mail.desktop before this change).
The new variable 'server-eval-args-left' allows access to the
arguments before they are parsed as Lisp. By removing
arguments from the variable before they're parsed, a snippet
of Lisp can consume arguments, as in emacsclient-mail.desktop.
org-protocol might be able to use this as well, which might allow it
to drop its current advice on server-visit-files.
* etc/emacsclient-mail.desktop: Use 'server-eval-args-left'.
* lisp/server.el (server-eval-args-left): New variable.
(server-process-filter, server-execute): Make '-eval' arguments
available through 'server-eval-args-left'.
* lisp/startup.el (argv): Mention 'server-eval-args-left' in
docstring.
* etc/NEWS: Announce 'server-eval-args-left'.
* doc/emacs/misc.texi (emacsclient Options): Document
'server-eval-args-left'. (Bug#65902)
Spencer Baugh [Sat, 21 Oct 2023 15:09:39 +0000 (11:09 -0400)]
Add 'case-symbols-as-words' to configure symbol case behavior
In some programming languages and styles, a symbol (or every
symbol in a sequence of symbols) might be capitalized, but the
individual words making up the symbol should never be capitalized.
For example, in OCaml, type names Look_like_this and variable names
look_like_this, but it is basically never correct for something to
Look_Like_This. And one might have "aa_bb cc_dd ee_ff" or "Aa_bb
Cc_dd Ee_ff", but never "Aa_Bb Cc_Dd Ee_Ff".
To support this, the new variable 'case-symbols-as-words' causes
symbol constituents to be treated as part of words only for case
operations.
* src/casefiddle.c (case_ch_is_word): New function.
(case_character_impl, case_character): Use 'case_ch_is_word'.
(syms_of_casefiddle): Define 'case-symbols-as-words'.
* src/search.c (Freplace_match): Use 'case-symbols-as-words'
when calculating case pattern.
* test/src/casefiddle-tests.el (casefiddle-tests--check-syms)
(casefiddle-case-symbols-as-words): Test 'case-symbols-as-words'.
* etc/NEWS: Announce 'case-symbols-as-words'.
* doc/lispref/strings.texi (Case Conversion): Document
'case-symbols-as-words'.
(Bug#66614)
Spencer Baugh [Sat, 21 Oct 2023 14:41:42 +0000 (10:41 -0400)]
Remove the header line after disabling 'which-function-mode'
Previously, the header line would stay around even when after
disabling 'which-function-mode', although it may be empty. Now
the 'which-function-mode' element is properly removed from
'header-line-format', so the header line will disappear if
there's nothing else in 'header-line-format'.
Also, previously, when we ran (which-function-mode), we would
enable
'which-function-mode' for all buffers even if they didn't support
imenu. We didn't run the normal logic in 'which-func-ff-hook' to
disable 'which-func-mode' if imenu wasn't present. Now we do run
that logic, by just calling 'which-func-ff-hook'. This is
especially important when the header line is enabled, because
otherwise there's a very noticeable header line added to every
buffer, including e.g. *Help* and *Buffer List*.
Also, we now check that 'header-line-format' is a list before trying
to add to it; this makes us work properly when enabling and
disabling 'which-function-mode' for modes which set
'header-line-format' to a string or symbol, such as eww.
* lisp/progmodes/which-func.el (which-func-try-to-enable): Re-add
'which-func-format' to the header line.
(which-func--header-line-remove): New function.
(which-func--disable): Call 'which-func--header-line-remove'.
(which-function-mode): Call 'which-func-ff-hook' and
'which-func--header-line-remove'. (bug#66283)
* test/lisp/progmodes/which-func-tests.el: New test.
Po Lu [Sun, 29 Oct 2023 04:59:45 +0000 (12:59 +0800)]
Avert a crash and file descriptor leak in yank-media
* java/org/gnu/emacs/EmacsNative.java (close): New declaration.
* java/org/gnu/emacs/EmacsSdk11Clipboard.java
(getClipboardData): Catch SecurityException and guarantee file
descriptors are closed even if exceptions arise.