Yuan Fu [Thu, 18 Aug 2022 08:44:39 +0000 (01:44 -0700)]
Add treesit-parser-delete
* src/treesit.c (ts_record_change): Replace CHECK_TS_PARSER with
ts_check_parser.
(make_ts_parser): Initialize deleted field.
(Ftreesit_parser_delete): Replace CHECK_TS_PARSER with
ts_check_parser. Set deleted field.
(Ftreesit_parser_buffer, Ftreesit_parser_language): Replace
CHECK_TS_PARSER with ts_check_parser.
(ts_check_parser): New function.
(Ftreesit_parser_root_node, Ftreesit_parser_set_included_ranges)
(Ftreesit_parser_included_ranges): Replace CHECK_TS_PARSER with
ts_check_parser.
(Qtreesit_parser_deleted): New symbol.
(Qtreesit_parser_deleted): New error.
* src/treesit.h (Lisp_TS_Parser): New field 'deleted'.
Yuan Fu [Fri, 17 Jun 2022 00:55:07 +0000 (17:55 -0700)]
Change treesit-parser-list from variable to function
Effectively making the list internal. Now Emacs user cannot shoot
themselves in the foot by removing a parser from the list, make
chaanges to buffer and add that parser back to the list.
* doc/lispref/parsing.texi (Language Definitions, Using Parser)
(Retrieving Node, Multiple Languages): Change variable to function.
* lisp/treesit.el (treesit-language-at, treesit-node-on)
(treesit-buffer-root-node, treesit-indent, treesit-check-indent)
(treesit-search-forward, treesit-search-beginning)
(treesit-end-of-defun, treesit-inspect-mode): Change variable to
function.
* src/buffer.c (bset_ts_parser_list, reset_buffer, init_buffer_once):
Add ts_parser_list.
* src/buffer.h (struct buffer): Add ts_parser_list.
* src/treesit.c (ts_record_change, Ftreesit_parser_create): Use the
buffer field instead of the old buffer local variable.
(Ftreesit_parser_delete, Ftreesit_parser_list): New functions.
(syms_of_treesit): Remove treesit-parser-list.
* test/src/treesit-tests.el (treesit-basic-parsing): Use the new
function.
ptrdiff_t start_offset =
min (visible_end,
max (visible_beg, start_byte)) - visible_beg;
ptrdiff_t old_end_offset =
min (visible_end,
max (visible_beg, old_end_byte)) - visible_beg;
ptrdiff_t new_end_offset =
min (visible_end,
max (visible_beg, new_end_byte)) - visible_beg;
Also previously only visible_end is changed (in a wrong way)
Yuan Fu [Tue, 14 Jun 2022 18:36:22 +0000 (11:36 -0700)]
Support compiled queries in treesit-query-capture
Last commit added this new type, this commit adds functionalities.
treesit.el only has documentation changes.
* lisp/treesit.el (treesit-query-in, treesit-font-lock-settings,
treesit-defun-query): Update docstring.
* src/treesit.c (make_ts_query): New function.
(Ftreesit_query_compile): New function.
(Ftreesit_query_capture): Remove code that creates a query object and
instead either use make_ts_query or use the give compiled query. Free
the query object conditonally.
(syms_of_treesit): New symbol.
Yuan Fu [Tue, 14 Jun 2022 06:01:04 +0000 (23:01 -0700)]
Add new type treesit-compiled-query
No intergration/interaction with the new type, just adding it.
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Add new type.
* src/alloc.c (cleanup_vector): Add gc for the new type.
* src/data.c (Ftype_of): Add switch case for the new type.
(syms_of_data): Add symbols for the new type.
* src/lisp.h (DEFINE_GDB_SYMBOL_BEGIN): Add new type.
* src/treesit.c (Ftreesit_compiled_query_p): New function.
(syms_of_treesit): Add symbol for the new type.
* src/treesit.h (struct Lisp_TS_Query): New struct.
(TS_COMPILED_QUERY_P, XTS_COMPILED_QUERY, CHECK_TS_COMPILED_QUERY):
New macros.
* src/print.c (print_vectorlike): Add printing for the new type.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker)
(byte-optimize-let-form, byte-optimize-letX):
* lisp/emacs-lisp/bytecomp.el (byte-compile-unwind-protect):
Simplify source optimisation and codegen code that can now rely on
normalised let/let* and unwind-protect forms.
Make cconv work for dynamically bound code and always run it.
This allows later stages to benefit from transformations and
normalisations in cconv.
* lisp/emacs-lisp/bytecomp.el (byte-compile-preprocess): Always run
cconv.
* lisp/emacs-lisp/cconv.el (cconv--analyze-function)
(cconv-analyze-form): In dynbound code, treat all variable bindings
as dynamic (lambda, let, let* and condition-case).
Early normalisation of setq during macroexpand-all allows later
stages, cconv, byte-opt and codegen, to be simplified and duplicated
checks to be eliminated.
* lisp/emacs-lisp/macroexp.el (macroexp--expand-all):
Normalise all setq forms to a sequence of (setq VAR EXPR).
Emit warnings if necessary.
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv-analyze-form):
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
* lisp/emacs-lisp/bytecomp.el (byte-compile-setq):
Simplify.
* test/lisp/emacs-lisp/bytecomp-tests.el: Adapt and add tests.
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-setq-nonvariable.el;
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-setq-odd.el:
New files.
Robert Pluim [Wed, 8 Jun 2022 12:51:31 +0000 (14:51 +0200)]
Add more characters with macron in C-x 8 map and latin input methods
* lisp/international/iso-transl.el (iso-transl-char-map): Add
sequences for {AE,ae,G,g} with macron.
* lisp/leim/quail/latin-post.el ("latin-postfix"): Add missing entries
for {AE,ae,G,g} with macron.
* lisp/leim/quail/latin-pre.el ("latin-prefix"): Add entries for
'letter with macron' for {A,a,E,e,AE,ae,I,I,O,o,U,u,Y,y} with macron.
* lisp/files.el (dir-locals-read-from-dir): We want the time stamp
of the actual file, not the time stamp of the symlink (if
.dir-locals.el is a symlink) (bug#46122).
Daniel Martín [Tue, 14 Jun 2022 12:23:06 +0000 (14:23 +0200)]
Bind Cmd-t to menu-set-font on macOS
* lisp/term/ns-win.el (global-map): set-frame-font asks for a font
using the minibuffer, but the former ns-popup-font-panel always showed
the graphical font panel on macOS. To preserve the same behavior,
bind it to menu-set-font, which is also called by Options, Set Default
Font (bug#55967).
Michael Albinus [Tue, 14 Jun 2022 11:04:34 +0000 (13:04 +0200)]
Fix Tramp problem with non-essential
* lisp/net/tramp.el (tramp-run-real-handler):
Handle also functions which use a `tramp-file-name' for the file
name handler. (Bug#55832)
(tramp-get-home-directory, tramp-get-remote-uid)
(tramp-get-remote-gid): VEC can also be nil.
Po Lu [Tue, 14 Jun 2022 05:52:38 +0000 (13:52 +0800)]
Handle coordinates of Motif drop start messages
* src/xterm.c (xm_read_drop_start_message): New function.
(xm_read_drag_motion_message): Check that the originator is
correct.
(x_coords_from_dnd_message): Read drop start messages as well.
Yuan Fu [Mon, 13 Jun 2022 20:22:17 +0000 (13:22 -0700)]
Fix treesit-search-forward
Move the check for movement
(if (> arg 0)
;; Make sure we moved forward.
(> (funcall pos-fn node) starting-point)
;; Make sure we moved backward.
(< (funcall pos-fn node) starting-point))
into cl-loop:
if (treesit-node-eq cap-node node)
becomes
if (and (treesit-node-eq cap-node node)
(if (> arg 0)
;; Make sure we moved forward.
(> (funcall pos-fn node)
starting-point)
;; Make sure we moved backward.
(< (funcall pos-fn node)
starting-point)))
* lisp/treesit.el (treesit-search-forward): Move the check.
* src/xfont.c (xfont_list_pattern): Initialize a local.
Although I’m not sure this is needed, it doesn’t change
behavior (except possibly to make undefined behavior defined).
Allow `query-replace' to do exact replacement of the current item
* doc/emacs/search.texi (Query Replace): Document it.
* lisp/replace.el (query-replace-help): Amend help text.
(query-replace-map): Bind `E' to the exact case replacement.
(perform-replace): Allow editing a replacement with exact case
(bug#8504).
* lisp/language/indian.el ("Meetei Mayek"): New language environment.
Add composition rules for Meetei Mayek. Add sample text and input method.
* lisp/international/fontset.el (script-representative-chars)
(setup-default-fontset): Support Meetei Mayek.
* lisp/leim/quail/indian.el ("meetei-mayek"): New input method.
* etc/HELLO: Add a Meetei Mayek greeting.
* etc/NEWS: Announce the new language environment.
* lisp/vc/ediff-wind.el (ediff-refresh-mode-lines): Don't include
"Quick Help" in the mode line in the plain version (bug#12840).
(ediff-make-wide-control-buffer-id): Make the informative part of
the mode line bold. (Code from Michael Heerdegen.)
Richard Hansen [Mon, 13 Jun 2022 12:32:01 +0000 (14:32 +0200)]
bindat (strz): Error on null byte if packing variable-length string
* lisp/emacs-lisp/bindat.el (strz): Signal an error if a null byte is
encountered while packing a string to a variable-length strz field.
* test/lisp/emacs-lisp/bindat-tests.el (strz): Add tests (bug#55938).
* lisp/emacs-lisp/package.el (package-menu-filter-by-archive):
Filter by package name instead of by regexp, so that if the user
types "gnu", they won't get "nongnu", too (bug#55919).
Po Lu [Mon, 13 Jun 2022 07:01:06 +0000 (15:01 +0800)]
Respect test function when performing local drag-and-drop
* lisp/x-dnd.el (x-dnd-test-function): Fix doc string to
describe what is actually accepted.
(x-dnd-known-types, x-dnd-targets-list): Fix coding style.
(x-dnd-handle-native-drop): New function.
* src/xselect.c (x_atom_to_symbol): Export.
* src/xterm.c (x_dnd_note_self_drop): Call new variable to
determine what action to return.
(x_clear_dnd_action): New function.
(x_dnd_begin_drag_and_drop): Respect new variable.
(syms_of_xterm): New defvar `x-dnd-native-test-function'.
* src/xterm.h: Update prototypes.
Po Lu [Mon, 13 Jun 2022 04:49:12 +0000 (12:49 +0800)]
Improve DND tooltip updating
* src/xterm.c (x_dnd_update_tooltip_now): Add missing part of
last change.
(x_monitors_changed_cb, handle_one_xevent): Only update if a
change in monitor configuration really happened.
Po Lu [Mon, 13 Jun 2022 01:11:08 +0000 (09:11 +0800)]
Fix special DND event coordinates
* src/xterm.c (x_dnd_note_self_drop): Set DND action to
XdndActionPrivate.
(x_dnd_begin_drag_and_drop): Don't return XdndPrivate specially
here.
(handle_one_xevent): Fix order of arguments to
x_dnd_note_self_drop.
When the regexp contains ^ or $ then use a temporary buffer to find matches
at the beginning/end of the region with the given text property (bug#14013).
Po Lu [Sun, 12 Jun 2022 13:04:19 +0000 (13:04 +0000)]
Fix handling of scroll bar clicks on Haiku
* src/haiku_support.cc (class EmacsView, BasicMouseDown)
(BasicMouseUp): Move MouseDown and MouseUp here. New parameter
`scroll_bar'.
(MouseDown, MouseUp): Call basic variants.
(class EmacsScrollBar): New field `parent'.
(BScrollBar_make_for_view): Rename to
`be_create_scroll_bar_for_view'.
* src/haiku_support.h (struct haiku_button_event): New field
`scroll_bar'.
* src/haikuterm.c (haiku_scroll_bar_from_widget): Handle NULL
widget.
(haiku_scroll_bar_create): Update calls.
(haiku_mouse_position): Fix scroll bar part.
(haiku_read_socket): Handle button events on scroll bars as
scroll bar click events.
Po Lu [Sun, 12 Jun 2022 08:41:40 +0000 (16:41 +0800)]
Fix phantom drag-and-drop targets showing up in some programs
* src/xterm.c (x_dnd_cleanup_drag_and_drop)
(x_dnd_begin_drag_and_drop): Delete XdndTypeList if it was set
after the DND operation completes. Some programs apparently
think its presence on the drag source means there are more than
3 targets.
* lisp/emacs-lisp/bindat.el (str) (strz): Signal an error if the user
attempts to pack a multibyte string containing characters other than
ASCII and `eight-bit' characters (bug#55897).
* doc/lispref/processes.texi (Bindat Types): Update documentation.
* test/lisp/emacs-lisp/bindat-tests.el (str) (strz): Add tests.
Yuan Fu [Sun, 12 Jun 2022 03:24:38 +0000 (20:24 -0700)]
Rename treesit-traverse-forward-depth-first
* lisp/treesit.el (treesit-traverse-forward): Rename to
'treesit-traverse-forward'.
(treesit-traverse-forward, treesit-search-forward): Use
the new name.
Po Lu [Sun, 12 Jun 2022 01:32:30 +0000 (09:32 +0800)]
Don't rely on XdndAware on frames for dropping to work
* src/xterm.c (x_dnd_get_target_window): New parameter
WAS_FRAME. If toplevel is a frame, set it and clear proto and
motif.
(x_dnd_send_enter, x_dnd_send_position, x_dnd_send_leave)
(x_dnd_send_drop): Remove special-cased self dropping code.
(x_dnd_note_self_position, x_dnd_note_self_drop): New functions.
(x_dnd_begin_drag_and_drop, x_dnd_update_state):
(handle_one_xevent): Handle our own frames using those functions
instead.