Yuan Fu [Sun, 2 Oct 2022 03:25:25 +0000 (20:25 -0700)]
Ignore some capture name in treesit-font-lock-fontify-region
* doc/lispref/modes.texi (Parser-based Font Lock): Update manual.
* lisp/treesit.el: (treesit-font-lock-fontify-region): Ignore names
that are not face nor function.
(treesit-font-lock-rules): Update docstring.
Yuan Fu [Sun, 25 Sep 2022 03:42:03 +0000 (20:42 -0700)]
Improve treesit-search-forward-goto
* doc/lispref/parsing.texi (Retrieving Node): Update manual.
* lisp/treesit.el (treesit-search-forward-goto): Instead of taking a
node, use the node at point, and make sure we make progress.
Yuan Fu [Sun, 25 Sep 2022 02:41:17 +0000 (19:41 -0700)]
Update and enable treesit-imenu function in python.el
* lisp/progmodes/python.el (python--treesit-settings): Add docstring.
(python--imenu-treesit-create-index-1): Rewrite with
treesit-induce-sparse-tree.
(python-imenu-treesit-create-index): Move main body to
python--imenu-treesit-create-index-1.
(python-imenu-treesit-create-flat-index): Fix typo.
(python-mode): Enable treesit-imenu. Also fix indentation for
which-func code.
Yuan Fu [Wed, 21 Sep 2022 01:01:15 +0000 (18:01 -0700)]
Rename treesit-expand-query/pattern
* src/treesit.c (treesit-expand-pattern): Rename to
treesit-patter-expand.
(treesit-expand-query): Rename to treesit-query-expand.
(make_ts_query): Use new name.
* test/src/treesit-tests.el (treesit-query-api): Fix name.
Yuan Fu [Wed, 21 Sep 2022 01:01:15 +0000 (18:01 -0700)]
Rename treesit-expand-query/pattern
* src/treesit.c (treesit-expand-pattern): Rename to
treesit-patter-expand.
(treesit-expand-query): Rename to treesit-query-expand.
(make_ts_query): Use new name.
Yuan Fu [Wed, 7 Sep 2022 20:20:37 +0000 (13:20 -0700)]
Remove treesit-disabled-modes and change treesit-should-enable-p
Per emacs-devel discussion, remove treesit-disabled-modes and let
major modes to provide tree-sitter switches. I also decided to add
treesit-max-buffer-size to elisp manual despite it being a user
option. Though we should still add it to the user manual.
* doc/lispref/parsing.texi (Parsing Program Source): Update manual to
remove entries for treesit-diabled-modes and add
treesit-max-buffer-size. Also update treesit-should-enable-p.
* lisp/treesit.el (treesit-disabled-modes): Remove user option.
(treesit-maximum-size): Change to treesit-max-buffer-size.
(treesit-should-enable-p): Change to treesit-can-enable-p and remove
checks of treesit-disabled-modes.
1. Add treesit-font-lock-rules that helps with settings
treesit-font-lock-settings.
2. Remove treesit-font-lock-defaults and with it, decoration levels.
Now major modes should set treesit-font-lock-settings with the output
of treesit-font-lock-rules rather than setting
treesit-font-lock-defaults.
* lisp/treesit.el (treesit-font-lock-settings): Update docstring.
(treesit-font-lock-rules): New function.
(treesit-font-lock-defaults): Remove variable.
(treesit-font-lock-enable): Remove code that interacts
treesit-font-lock-defaults.
* doc/lispref/modes.texi: Update manual for
treesit-font-lock-settings, treesit-font-lock-rules,
treesit-font-lock-defaults.
Eli Zaretskii [Sat, 27 Aug 2022 10:13:48 +0000 (13:13 +0300)]
Fix antialias face attribute when text is scaled
This restores the code we had in realize_gui_face before commit bf0d3f7.
The problem described in bug#17973, which led to that commit, only
happens if one uses a specific (misc-fixed) font family, not for
the usual default fonts used by Emacs, and I'm not sure what's
described there is a bug at all. At least for the purposes of
text-scale-adjust, it makes no sense to ignore the
foundry/family/adstyle of the original font, because we _want_ the
same (or very similar) font, just of a different size.
And likely in other use cases: if the :font attribute of a face
specifies some font properties, we want to keep them all, not
arbitrarily to ignore some of them. And definitely catering to an
obscure use case such as the one cited in bug#17973 is NOT a good
reason to make such radical changes in face-realization behavior.
So I think backing out that part of commit bf0d3f7 is TRT, and if
we decide that this causes bug#17973 in too many situations we care
about, I'd rather find a kludge for that specific case than do that
for every face realization.
* src/xfaces.c (realize_gui_face): Preserve face attributes when
text is scaled. This reverts part of the changes installed in
commit bf0d3f7. (Bug#37473)
Po Lu [Sat, 27 Aug 2022 01:54:16 +0000 (09:54 +0800)]
Fix crash when handling "swallowed" generic events
* src/xmenu.c (x_menu_translate_generic_event, x_menu_show):
Pass through more events, correctly.
* src/xterm.c (handle_one_xevent): Don't abort if must_free_data
and xi_event is NULL; this is an Xlib bug.
Alan Mackenzie [Fri, 26 Aug 2022 15:51:21 +0000 (15:51 +0000)]
CC Mode: Fontify correctly a brace list element followed only by syntactic WS
This fixes a regression introduced in the fix for bug #56841 on 2022-08-24.
* lisp/progmodes/cc-engine (c-forward-declarator): Allow point to be at EOB
after the call to c-forward-name, rather than rejecting it as an invalid
declarator. Also reindent a section of this function.
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times):
Use `eval-when-compile'.
(tramp-adb-maybe-open-connection): Use file-property for "/". Use
`eval-when-compile'.
* lisp/net/tramp-cmds.el (mm-7bit-chars): Declare.
(tramp-reporter-dump-variable): Simplify point movement.
* lisp/net/tramp-gvfs.el (tramp-dbus-function): Fix typo.
(tramp-zeroconf-parse-device-names): Use `tramp-prefix-port-format'.
* lisp/net/tramp-sh.el (tramp-open-shell, tramp-find-shell):
Use `eval-when-compile'. Improve sanity check.
* lisp/net/tramp.el (tramp-prefix-format, tramp-prefix-regexp)
(tramp-method-regexp, tramp-postfix-method-format)
(tramp-postfix-method-regexp, tramp-prefix-ipv6-format)
(tramp-prefix-ipv6-regexp, tramp-postfix-ipv6-format)
(tramp-postfix-ipv6-regexp, tramp-postfix-host-format)
(tramp-postfix-host-regexp, tramp-remote-file-name-spec-regexp)
(tramp-file-name-structure, tramp-file-name-regexp)
(tramp-completion-method-regexp)
(tramp-completion-file-name-regexp): Declare.
(tramp-set-syntax): Set also `tramp-completion-method-regexp'.
(tramp-volume-letter-regexp, tramp-completion-method-regexp-alist):
New defconsts.
(tramp-build-completion-method-regexp): New defun.
(tramp-completion-method-regexp): New defvar.
(tramp-completion-file-name-regexp-default)
(tramp-completion-file-name-regexp-simplified)
(tramp-completion-file-name-regexp-separate)
(tramp-completion-file-name-regexp-alist): Remove.
(tramp-build-completion-file-name-regexp): Rwrite.
(tramp-make-tramp-file-name): Use `tramp-archive-method'.
(tramp-handle-file-directory-p): Ignore errors.
(tramp-handle-find-backup-file-name, tramp-handle-lock-file)
(tramp-handle-make-auto-save-file-name): Use `eval-when-compile'.
* test/lisp/net/tramp-archive-tests.el:
* test/lisp/net/tramp-tests.el: Use `rx' where possible.
(tramp-test01-file-name-syntax): Adapt test.
Make the *Ido COmpletions* buffer fit the window to the buffer
* lisp/ido.el (ido-completion-help): Display the ido completions
buffer pretty much the same way that the default *Completions*
buffer is displayed (bug#50671). This means that we're defaulting
to fit-window-to-buffer.
* lisp/play/gamegrid.el (gamegrid-make-glyph): Declare
image-scaling-factor as special before dynamically binding it, for
the sake of --without-x builds which do not preload lisp/image.el.
* test/lisp/xt-mouse-tests.el (with-xterm-mouse-mode): Replace
deprecated generalized variables frame-width and frame-height with
direct calls to set-frame-width and set-frame-height, respectively.
Po Lu [Fri, 26 Aug 2022 01:42:35 +0000 (09:42 +0800)]
Restore old code in x_sync_trigger_fence
* src/xterm.c (x_sync_trigger_fence): Restore old code, since that
makes it easier to adapt to more than 2 sync fences (which might be
necessary in the future, if we ever decide to do frame handling
asynchronously), and is much more recognizable for people coming from
other programs.
Paul Eggert [Wed, 24 Aug 2022 01:18:13 +0000 (18:18 -0700)]
Fix overflows in HAVE_XSYNC timestamp handling
Also, port to platforms lacking CLOCK_MONOTONIC and int64_t, and
use 0 more consistently to represent missing timestamps.
* src/xterm.h (struct x_display_info):
Omit server_time_monotonic_p and server_time_offset if
!HAVE_CLOCK_GETTIME since they are unused in that case.
* src/xterm.h (struct x_display_info, struct x_output):
* src/xterm.c (x_sync_get_monotonic_time)
(x_sync_current_monotonic_time, x_sync_note_frame_times):
Use int_fast64_t instead of int64_t as POSIX doesn't
guarantee the latter. Similarly for uint_fast64_t.
(x_sync_get_monotonic_time, x_sync_current_monotonic_time)
(x_sync_note_frame_times, x_display_set_last_user_time):
Check for integer overflow in time arithmetic.
(CLOCK_MONOTONIC): Define to CLOCK_REALTIME if absent.
(x_sync_current_monotonic_time): Check for clock_gettime failure
and fall back on CLOCK_REALTIME if CLOCK_MONOTONIC does not work,
which POSIX allows.
(x_sync_current_monotonic_time, x_sync_note_frame_times)
(x_display_set_last_user_time):
Use 0 more consistently to represent missing timestamps.
(c-lang-const c-make-mode-syntax-table) already returns a function,
so quote it to avoid double evaluation since it could fail if the
function is not self-evaluating, such as when it's a symbol or
a value of the form (closure ...).
Stefan Kangas [Thu, 25 Aug 2022 16:46:48 +0000 (18:46 +0200)]
Improve explanation of init file in FAQ
* doc/misc/efaq.texi (Setting up a customization file): Improve
and update section to reflect current behavior. Add
cross-references back to this section.
* doc/emacs/custom.texi (Init File): Add comment to remind about
also updating the FAQ.
Ref: https://lists.gnu.org/r/emacs-devel/2022-08/msg01056.html
Stefan Kangas [Thu, 25 Aug 2022 16:06:30 +0000 (18:06 +0200)]
Don't refer to Emacs 24.3 or older in FAQ
* doc/misc/efaq.texi: Don't say that the FAQ has been edited.
(Displaying the current line or column, Automatic indentation)
(Problems with very large files, Emacs for other operating systems)
(Right-to-left alphabets, Expanding aliases when sending mail): Remove
references to Emacs 24.3 or older.
(Learning how to do something): Don't include the reference card
price; it is currently incorrect and is likely to be incorrect again
in the future.
Robert Pluim [Thu, 25 Aug 2022 16:13:16 +0000 (18:13 +0200)]
Treat smtp-auth method from auth-info as a symbol
The lookup of the SMTP auth method is done based on symbols, but
sometimes the requested value comes from `auth-info', in which case it
is a string, so call `intern-soft' to convert it to a symbol (which
does nothing if it's already a symbol).
* lisp/mail/smtpmail.el (smtpmail-try-auth-methods): Call
`intern-soft' on the smtp-auth key's value. (Bug#57373)
Robert Pluim [Thu, 25 Aug 2022 09:47:57 +0000 (11:47 +0200)]
Treat smtp-auth method from auth-info as a symbol
The lookup of the SMTP auth method is done based on symbols, but
sometimes the requested value comes from `auth-info', in which case it
is a string, so call `intern-soft' to convert it to a symbol (which
does nothing if it's already a symbol).
* lisp/mail/smtpmail.el (smtpmail-try-auth-methods): Call
`intern-soft' on the smtp-auth key's value. (Bug#57373)
* lisp/emacs-lisp/bytecomp.el (byte-compile-warn-obsolete):
Autoload so that the call here from gv.el (about obsolete
generalized variables) doesn't bug out (bug#57394).
Daniel Martín [Thu, 25 Aug 2022 12:37:36 +0000 (14:37 +0200)]
Fix instrumented eval-defun not printing "Edebug:" to the echo area
* lisp/progmodes/elisp-mode.el (elisp--eval-defun): Determine if we're
instrumenting a function and call eval-region with PRINTFLAG set to
nil if so (Bug#50245).
* test/lisp/progmodes/elisp-mode-tests.el
(eval-defun-prints-edebug-when-instrumented): Add a new test.
kobarity [Thu, 25 Aug 2022 12:29:10 +0000 (14:29 +0200)]
Add Python blocks support for hideshow
* lisp/progmodes/python.el (python-nav-beginning-of-block-regexp):
New variable.
(python-hideshow-forward-sexp-function): Change to call
`python-nav-end-of-block'.
(python-hideshow-find-next-block): New function to be used as
FIND-NEXT-BLOCK-FUNC in `hs-special-modes-alist'.
(python-info-looking-at-beginning-of-block): New function to be
used as LOOKING-AT-BLOCK-START-P-FUNC in `hs-special-modes-alist'.
(python-mode): Change settings of `hs-special-modes-alist'.
* test/lisp/progmodes/python-tests.el
(python-hideshow-hide-levels-1): Fix to keep empty lines.
(python-info-looking-at-beginning-of-block-1)
(python-hideshow-hide-levels-3, python-hideshow-hide-levels-4)
(python-hideshow-hide-all-1, python-hideshow-hide-all-2)
(python-hideshow-hide-all-3, python-hideshow-hide-block-1): New
tests (bug#56635).
kobarity [Thu, 25 Aug 2022 12:28:22 +0000 (14:28 +0200)]
Extend `hs-special-modes-alist' for languages such as Python
* lisp/progmodes/hideshow.el (hs-special-modes-alist): Add
elements FIND-BLOCK-BEGINNING-FUNC, FIND-NEXT-BLOCK-FUNC, and
LOOKING-AT-BLOCK-START-P-FUNC.
(hs-find-block-beginning-func): New variable to hold
FIND-BLOCK-BEGINNING-FUNC.
(hs-find-next-block-func): New variable to hold
FIND-NEXT-BLOCK-FUNC.
(hs-looking-at-block-start-p-func): New variable to hold
LOOKING-AT-BLOCK-START-P-FUNC.
(hs-grok-mode-type): Set new variables from
`hs-special-modes-alist'.
(hs-find-next-block): New function.
(Misc.): Update callers of the above functions.
* test/lisp/progmodes/hideshow-tests.el: New test file (bug#56635).
Allow not deleting the config.cache file with "make FAST=true bootstrap"
* Makefile.in: Add some commentary about make bootstrap,
./configure -C and FASTo
(top_bootclean): Don't delete config.cache here.
(top_distclean): Delete it here instead.
(bootstrap-clean): Allow not deleting the cache file.
Michael Albinus [Thu, 25 Aug 2022 09:08:48 +0000 (11:08 +0200)]
Minor fixes in tramp-tests.el
* test/lisp/net/tramp-tests.el (tramp--test-deftest-with-stat)
(tramp--test-deftest-with-perl)
(tramp--test-deftest-with-ls): Skip if underlying test didn't run
or lasted too long.
(tramp--test-shell-file-name): Do not depend on `tramp--test-adb-p'.
Po Lu [Thu, 25 Aug 2022 04:24:34 +0000 (12:24 +0800)]
Fix various problems with mouse highlight on XI2 builds
* src/dispextern.h (reset_mouse_highlight): Fix coding style.
* src/xterm.c (xi_position_changed): New functions.
(xi_report_motion_window_clear, handle_one_xevent): Don't report
motion events if the pixel position did not actually change.
* src/xterm.h (struct xi_device_t): New fields
`last_motion_window', `last_motion_x' and `last_motion_y'.
Alan Mackenzie [Wed, 24 Aug 2022 19:27:32 +0000 (19:27 +0000)]
C++ Mode - Fontify "class Foo {\n ~Foo() noexcept;" correctly
This fixes bug #49787.
* lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): (In `if' form just
before CASE 8) Remove the (not ...) around the (looking-at
c-after-suffixed-type-maybe-decl-key).
* lisp/progmodes/cc-fonts.el (c-font-lock-complex-decl-prepare): Add
`c-not-decl' to the values of c-type which are erased at the start of a
fontification.
Alan Mackenzie [Wed, 24 Aug 2022 14:42:11 +0000 (14:42 +0000)]
CC Mode: Fontify args correctly when arglist closing ) is not on the same line
This fixes bug #56841.
* lisp/progmodes/cc-engine.el (c-forward-declarator): Fix an off-by-one
comparing the position after a c-forward-name with a limit.
* lisp/progmodes/cc-mode.el (c-fl-decl-end): Handle correctly point starting
inside a literal. Insert a missing c-backward-syntactic-ws in the handling of
C++ attributes. Correctly handle an unmatched (. Better handle point
starting inside a [ or (. Tidy up the handling of syntactic whitespace at the
end of the buffer.