João Távora [Sun, 15 Aug 2021 12:19:59 +0000 (13:19 +0100)]
Sort by recency in flex completion style when no flexy stuff happening
Fixes: bug#49888
* minibuffer.el (completion--flex-adjust-metadata): Fall back to usual
alphanumeric, length, recency strategy if no minibuffer input. There
is still a bug indicated by the nearby FIXMEs, though.
Run execute-extended-command key binding suggestion from a timer
* lisp/simple.el (execute-extended-command): Run the key binding
suggestion from a timer instead of in the program flow -- this
allows `post-command-hook' to be executed immediately (bug#50042).
Eli Zaretskii [Sun, 15 Aug 2021 11:11:23 +0000 (14:11 +0300)]
Fix unwarranted point movement after C-g
When the same buffer is displayed in more than one window,
redisplay temporarily moves point to the window-point when it
works on non-selected windows. If we allow C-g to quit out of
redisplay_window in this situation, point will appear to have
moved to the window-point of that non-selected window, which is
unwarranted. These changes prevent quitting in strategic places,
so that we never quit out of redisplay_window.
* src/xdisp.c (run_window_scroll_functions):
Prevent quitting while running window-scroll-functions, so that we
don't quit out of redisplay_window with temporarily moved point.
(redisplay_window): While redisplaying the mode line, prevent
quitting, to avoid exiting while point is temporarily moved.
(decode_mode_spec): Use safe_call1 instead of call1, to trap any
errors instead of letting them throw out of redisplay. (Bug#44448)
João Távora [Sun, 15 Aug 2021 08:12:23 +0000 (09:12 +0100)]
Fix bug#50063 when using icomplete-fido-kill with C-x p p
C-x p p utilizes a completion table "category" which is 'project-file'
icomplete-fido-kill only functioned for 'buffer' and 'file', and
failed with a non-informative message when something else was used.
* lisp/icomplete.el (icomplete-fido-kill): Support 'project-file'
class. Use cl-case, instead of pcase.
João Távora [Sun, 15 Aug 2021 08:12:23 +0000 (09:12 +0100)]
Fix bug#50063 when using icomplete-fido-kill with C-x p p
C-x p p utilizes a completion table "category" which is 'project-file'
icomplete-fido-kill only functioned for 'buffer' and 'file', and
failed with a non-informative message when something else was used.
* lisp/icomplete.el (icomplete-fido-kill): Support 'project-file'
class. Use cl-case, instead of pcase.
João Távora [Sat, 14 Aug 2021 08:25:35 +0000 (09:25 +0100)]
Allow completion frontends to highlight completion strings just in time
This allows completion-pcm--hilit-commonality to be sped up
substantially.
Introduce a new variable completion-lazy-hilit that allows for
completion frontends to opt-in an time-saving optimization by some
completions styles, such as the 'flex' and 'pcm' styles.
The variable must be set by the frontend to a unique value around a
completion attempt/session. See completion-lazy-hilit docstring for
more info.
* lisp/minibuffer.el (completion-lazy-hilit): New variable.
(completion-lazy-hilit): New function.
(completion-pcm--hilit-commonality): Use completion-lazy-hilit.
* lisp/emacs-lisp/map.el: Bump version to 3.1.
(map--merge): New merging subroutine that uses a hash table in place
of lists, for both efficiency and avoiding ambiguities (bug#49848).
(map-merge): Rewrite in terms of map--merge.
(map-merge-with): Ditto. This ensures that FUNCTION is called
whenever two keys are merged, even if they are not eql (which could
happen until now). It also makes map-merge-with consistent with
map-merge, thus achieving greater overall predictability.
* etc/NEWS: Announce this weakening of guarantees.
* test/lisp/emacs-lisp/map-tests.el (test-map-merge)
(test-map-merge-with): Don't depend on specific orderings. Test
that nil is correctly merged into a plist.
This face is intended for mark-up syntax and constructs inside text
using font-lock-doc-face; ie, documentation comments and strings in
programming modes.
* lisp/font-lock.el (font-lock-doc-markup-face): New face.
* lisp/cus-theme.el (custom-theme--listed-faces): Add it to the list.
* doc/lispref/modes.texi (Faces for Font Lock): Document it.
* etc/NEWS: Mention it.
Alan Mackenzie [Fri, 13 Aug 2021 20:58:30 +0000 (20:58 +0000)]
CC Mode: Fix a bug in yesterday's patch
* lisp/progmodes/cc-mode.el (c-before-change-check-unbalanced-strings): Check
the language has multi-line strings before calling
c-ml-string-opener-at-or-around-point.
Unknown line endings in filepos-to-bufferpos/bufferpos-to-linepos
* lisp/international/mule-util.el (filepos-to-bufferpos): Give
better errors on `exact' with unknown line endings, and guess at
Unix if `approximate' (bug#36573).
(bufferpos-to-filepos): Ditto.
(tab-bar-format-history): Don't use this recently added variable
because now it's possible to customize the option 'tab-bar-format'
to remove 'tab-bar-format-history' from it that gives the same result.
Juri Linkov [Fri, 13 Aug 2021 07:10:29 +0000 (10:10 +0300)]
Add save-some-buffers-root to save-some-buffers-default-predicate (bug#46374)
* lisp/files.el (save-some-buffers-default-predicate): Add choice
'save-some-buffers-root'.
(save-some-buffers-root): New predicate function.
(save-some-buffers): Check if 'pred' returns a lexically-bound lambda,
then use it as 'pred'.
Alan Mackenzie [Thu, 12 Aug 2021 19:04:28 +0000 (19:04 +0000)]
CC Mode: Enhance C++ Mode raw strings to multi-line strings for any language
* lisp/progmodes/cc-defs.el (cadar, caddr, cdddr): Add defsubsts for these for
when they are missing from the host Emacs.
(c-point): Add new `position' 'boll "beginning of logical line".
(c-clear-char-properties): Return the position of the lowest removed
property.
* lisp/progmodes/cc-engine.el (c-full-pp-to-literal): Fix for rare case where
LIMIT < START in parse-partial-sexp.
(c-old-beg-rs, c-old-end-rs, c-raw-string-end-delim-disrupted)
(c-raw-string-pos, c-raw-string-in-end-delim, c-depropertize-raw-string)
(c-depropertize-raw-strings-in-region, c-before-change-check-raw-strings)
(c-propertize-raw-string-id, c-propertize-raw-string-opener): Old functions
and variables removed or renamed "raw" -> "ml" and adapted.
(c-old-beg-ml, c-old-1-beg-ml, c-old-end-ml, c-beg-pos, c-end-pos)
(c-ml-string-end-delim-disrupted, c-depropertize-ml-string-delims)
(c-ml-string-delims-around-point,c-position-wrt-ml-delims)
(c-before-change-check-ml-strings, c-after-change-unmark-ml-strings)
(c-maybe-re-mark-ml-string, c-propertize-ml-string-id)
(c-propertize-ml-string-opener, c-depropertize-ml-string)
(c-depropertize-ml-strings-in-region): New functions and variables adapted and
possibly renamed from "raw" -> "ml".
(c-ml-string-make-closer-re, c-ml-string-make-opener-re)
(c-c++-make-ml-string-closer-re, c-c++-make-ml-string-opener-re)
(c-get-ml-closer, c-ml-string-opener-around-point)
(c-ml-string-opener-intersects-region, c-ml-string-opener-at-or-around-point)
(c-ml-string-back-to-neutral, c-ml-string-in-end-delim, c-neutralize-pos)
(c-neutralized-prop): New functions and variables.
* lisp/progmodes/cc-fonts.el (c-basic-matchers-before): Replace
c-font-lock-raw-strings with c-font-lock-ml-strings.
(c-font-lock-ml-strings): New function taking the place of the old
c-font-lock-ml-strings.
* lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Move
c-depropertize-CPP to the second item of the C++ entry, and replace
c-before-change-check-raw-strings by c-before-change-check-ml-strings. Add a
new entry for Pike Mode.
(c-before-font-lock-functions): (Replace c-after-change-unmark-raw-strings by
c-after-change-unmark-ml-strings in the C++ entry, and add a new entry for
Pike Mode.
(c-ml-string-backslash-escapes, c-ml-string-non-punc-skip-chars)
(c-ml-string-opener-re, c-ml-string-max-opener-len, c-ml-string-any-closer-re)
(c-ml-string-max-closer-len, c-ml-string-max-closer-len-no-leader)
(c-ml-string-back-closer-re, c-make-ml-string-closer-re-function)
(c-make-ml-string-opener-re-function, c-ml-string-cpp-or-opener-re)
(c-cpp-or-ml-match-offset): New c-lang-defconsts and c-land-defvars.
(c-multiline-string-start-char): Remove the Pike Mode setting.
* lisp/progmodes/cc-mode.el (c-depropertize-CPP): Test for general ml strings
rather than C++ raw strings.
(c-unescaped-nls-in-string-p): Handle languages with ml strings.
(c-clear-string-fences): Fix bug with wrong parenthesisation.
(c-before-change-check-unbalanced-strings)
(c-after-change-mark-abnormal-strings, c-after-change-escape-NL-in-string):
Adapt for multi-line strings.
Michael Albinus [Thu, 12 Aug 2021 18:09:48 +0000 (20:09 +0200)]
Improve connection type `pipe' for remote processes
* doc/misc/tramp.texi (Remote processes): New subsection "Remote
process connection type".
* lisp/net/tramp-adb.el (tramp-adb-handle-make-process):
Use `tramp-process-connection-type' as default connection type.
Improve check for `:connection-type'.
* lisp/net/tramp-sh.el (tramp-sh-handle-make-process):
Use `tramp-process-connection-type' as default connection type.
Improve check for `:connection-type'. Send "stty -icrnl" when
connection type is a pipe.
* lisp/net/tramp.el (tramp-process-connection-type): Allow all
possible values.
(tramp-handle-make-process): Use `tramp-process-connection-type'
as default connection type. Improve check for `:connection-type'.
* lisp/startup.el (normal-top-level): Make startup more robust --
we may not be allowed to create any directories when running under
test mode (bug#48350).
Allow using XLFD font names with dashes in the family name
* src/font.c (font_parse_xlfd_1): Rename from font_parse_xlfd to
allow calling twice from a wrapper (bug#35816).
(font_parse_xlfd): Wrapper function -- first try to parse in the
normal way, and then try to guess that the hyphenated bits are in
the family name.
Peter Münster [Wed, 11 Aug 2021 16:02:25 +0000 (18:02 +0200)]
Add new image-dired commands
* lisp/image-dired.el (image-dired-delete-marked): Factored out
(bug#50000).
(image-dired-display-thumbs): From here.
(image-dired-tag-marked-thumbnails): New command.
(image-dired-delete-marked): Ditto.
Peter Münster [Wed, 11 Aug 2021 12:03:23 +0000 (14:03 +0200)]
Mark marked images in Image-Dired mode
* lisp/image-dired.el (image-dired-thumb-update-marks): New
function that makes the marks visible in the thumbnail buffer
(bug#49988).
(image-dired-thumb-margin, image-dired-thumb-mark-color): New user
options.
Peter Münster [Wed, 11 Aug 2021 11:39:53 +0000 (13:39 +0200)]
Let image-dired-mouse-toggle-mark act on active region
* lisp/image-dired.el (image-dired-mouse-toggle-mark): When region is
active, then toggle marks of all images within (bug#49987).
(image-dired-mouse-toggle-mark-1): Separated out into function.
Juri Linkov [Wed, 11 Aug 2021 07:06:29 +0000 (10:06 +0300)]
* lisp/replace.el (perform-replace): Use 'remove-function' (bug#49963).
Don't let-bind the value of 'isearch-filter-predicate' to protect
from changing the global value, since with a buffer-local value
it still changes the global value. So after using 'add-function' on the
global value of 'isearch-filter-predicate', call 'remove-function' to remove
'region-filter' from the global value in 'unwind-protect'.
* doc/misc/gnus.texi (Topic Variables): Document it.
* lisp/gnus/gnus-topic.el (gnus-topic-prepare-topic): New user option.
(gnus-topic-prepare-topic): Use it.
More robust auto-detect of grep-highlight-matches (bug#49978)
* lisp/progmodes/grep.el (grep-compute-defaults):
Don't require "grep --help" to finish with exit status 0 (BSD grep
does not) and check the output in a slightly more robust way.
* lisp/gnus/nnrss.el (nnrss-get-namespace-prefix): Use the car of
parameter el to match what dom-search expects.
* test/lisp/gnus/nnrss-tests.el (test-nnrss-xml): Adjust to what
xml-parse-region produces (bug#34685).
Tramp string-search and string-replace compatibility functions
Add a `string-search` compatibility function for use in Tramp with
Emacs version prior to 28, and fix the existing `string-replace`
compatibility function so that it uses the right semantics.
* lisp/net/tramp-compat.el (tramp-compat-string-replace):
Use case-sensitive matching and literal replacement.
(tramp-compat-string-search): New function.
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-name-all-completions):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-name-all-completions)
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-sh-handle-make-process, tramp-sh-handle-process-file):
* lisp/net/tramp.el (tramp-handle-make-process):
Use `tramp-compat-string-search` instead of `string-match-p`.
`string-search` is easier to understand, less error-prone, much
faster, does not pollute the regexp cache, and does not mutate global
state. Use it where applicable and obviously safe (erring on the
conservative side).
Tassilo Horn [Sun, 8 Aug 2021 14:45:50 +0000 (16:45 +0200)]
Un-obsolete dired-in-this-tree-p and use it again in certain places.
This reverts parts of b425966b07, and 7b50ed553f, i.e. it reverts the
obsoletion of dired-in-this-tree-p and switches some new callers of
file-in-directory-p back to using dired-in-this-tree-p.
It turned out that using file-in-directory-p can be a major
performance regression in case you have a dired buffer of a remote
directory which has become (almost) inaccessible.
Any attempt to open a new dired buffer is checking if a buffer for
that directory already exists (in terms of dired-buffers-for-dir)
which meant that file-in-directory-p was called with the directory of
any existing dired buffer including the inaccessible one where the
file-truename call in file-in-directory-p could block for seconds or
even minutes.
* lisp/dired.el (dired-in-this-tree-p): Undo obsoletion.
(dired-buffers-for-dir): Use dired-in-this-tree-p as before.
* lisp/dired-aux.el (dired-kill-tree,dired-tree-down): Une
dired-in-this-tree-p as before.
Use string-replace instead of replace-regexp-in-string
`string-replace` is easier to understand, less error-prone, much
faster, and results in shorter Lisp and byte code. Use it where
applicable and obviously safe (erring on the conservative side).