unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin <law@martinmarshall.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 68487@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#68487: [PATCH] Make jump commands usable for all skeletons
Date: Thu, 21 Mar 2024 20:05:04 -0400	[thread overview]
Message-ID: <87h6gzxhan.fsf@martinmarshall.com> (raw)
In-Reply-To: <86o7bhb6ak.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Mar 2024 09:50:59 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

> Ping!  Martin, can you please respond to Stefan's comments, so we
> could move forward with this issue?

Sorry for the long delay in responding.  I'll try to get to this by the
end of the weekend.


>> Cc: 68487@debbugs.gnu.org
>> Date: Sat, 02 Mar 2024 23:07:18 -0500
>> From:  Stefan Monnier via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> 
>> >> Ideally this should go along with the removal of the use of a vector in
>> >> `expand-list`, which not only is odd given its name but is odd because
>> >> it seems completely useless.
>> >
>> > Nothing (at least nothing in Emacs core) stores a vector to
>> > `expand-list`.  So I'm curious why `expand-abbrev-hook` was written to
>> > account for that possibility.
>> 
>> It's because it internally did that, tho I don't know why it did that
>> internally since my patch seems to show that it's simpler not to.
>> 
>> > Changing `expand-abbrev-hook` to expect `expand-list` to actually be a
>> > list (as you did with your patch) makes sense to me.
>> 
>> Should I install it, so it's kept separate from the changes you add
>> on top (mostly for readability of the patches)?
>> 
>> > What do you think?
>> 
>> I find the patch a bit hard to read, maybe for lack of a separate
>> description of the intended changes, or maybe because it does too much
>> in a single step.
>> 
>> I have one question, tho:
>> 
>> >  (defun expand-do-expansion ()
>> > -  (delete-char (- (length last-abbrev-text)))
>> > -  (let* ((vect (symbol-value last-abbrev))
>> > -	 (text (aref vect 0))
>> > -	 (position (aref vect 1))
>> > -	 (jump-args (aref vect 2))
>> > -	 (hook (aref vect 3)))
>> > -    (cond (text
>> > -	   (insert text)
>> > -	   (setq expand-point (point))))
>> > -    (if jump-args
>> > -        (funcall #'expand-build-list (car jump-args) (cdr jump-args)))
>> > -    (if position
>> > -	(backward-char position))
>> > -    (if hook
>> > -	(funcall hook))
>> > -    t))
>> > -
>> > -(defun expand-abbrev-from-expand (word)
>> > -  "Test if an abbrev has a hook."
>> > -  (or
>> > -   (and (intern-soft word local-abbrev-table)
>> > -	(symbol-function (intern-soft word local-abbrev-table)))
>> > -   (and (intern-soft word global-abbrev-table)
>> > -	(symbol-function (intern-soft word global-abbrev-table)))))
>> > -
>> > -(defun expand-previous-word ()
>> > -  "Return the previous word."
>> > -  (save-excursion
>> > -    (let ((p (point)))
>> > -      (backward-word 1)
>> > -      (buffer-substring p (point)))))
>> > +  ;; expand-point tells us if we have inserted the text
>> > +  ;; ourself or if it is the hook which has done the job.
>> > +  (if (listp expand-list)
>> > +      (setq expand-index 0
>> > +	    expand-pos (expand-list-to-markers expand-list)
>> > +	    expand-list nil))
>> > +  (run-hooks 'expand-expand-hook))
>> 
>> Hmm... but this `expand-do-expansion` doesn't actually "do" any
>> expansion any more, right?
>> 
>> >  (defun expand-skeleton-end-hook ()
>> > -  (if skeleton-positions
>> > -      (setq expand-list skeleton-positions)))
>> > +  (when skeleton-positions
>> > +    (setq expand-list skeleton-positions)
>> > +    (expand-do-expansion)))
>> 
>> Here if you read the code out loud it doesn't make sense to call 
>> `expand-do-expansion` since skeleton has already "done the expansion".
>> 
>> 
>>         Stefan
>> 
>> 
>> 
>> 
>> 

-- 
Best regards,
Martin Marshall





  reply	other threads:[~2024-03-22  0:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15 20:45 bug#68487: [PATCH] Make jump commands usable for all skeletons Martin Marshall
2024-01-27  9:13 ` Eli Zaretskii
2024-01-27 18:27   ` Martin Marshall
2024-01-27 18:51     ` Eli Zaretskii
2024-01-27 21:48       ` Martin Marshall
2024-01-28  5:52         ` Eli Zaretskii
2024-01-28 18:47           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-28 19:24             ` Eli Zaretskii
2024-01-28 19:45 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-05 21:46   ` Martin Marshall
2024-02-06  2:46     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-06 22:11       ` Martin Marshall
2024-02-07 17:13         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-26  1:26           ` Martin Marshall
2024-03-03  4:07             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-14  7:50               ` Eli Zaretskii
2024-03-22  0:05                 ` martin [this message]
2024-04-06  8:56                   ` Eli Zaretskii
2024-04-18  8:58                     ` Eli Zaretskii
2024-05-02  8:37                       ` Eli Zaretskii
2024-05-18  8:28                         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h6gzxhan.fsf@martinmarshall.com \
    --to=law@martinmarshall.com \
    --cc=68487@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).