From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: martin Newsgroups: gmane.emacs.bugs Subject: bug#68487: [PATCH] Make jump commands usable for all skeletons Date: Thu, 21 Mar 2024 20:05:04 -0400 Message-ID: <87h6gzxhan.fsf@martinmarshall.com> References: <877ckawckc.fsf@martinmarshall.com> <875xz2y46o.fsf@martinmarshall.com> <87il316y4w.fsf@martinmarshall.com> <875xycyq0x.fsf@martinmarshall.com> <86o7bhb6ak.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3929"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 68487@debbugs.gnu.org, Stefan Monnier To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 22 01:15:47 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rnSZW-0000oX-EQ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 Mar 2024 01:15:46 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnSZA-000757-W5; Thu, 21 Mar 2024 20:15:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnSZ9-00074v-MY for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2024 20:15:23 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnSZ9-0005DQ-71 for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2024 20:15:23 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rnSZl-0006fg-SG for bug-gnu-emacs@gnu.org; Thu, 21 Mar 2024 20:16:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Mar 2024 00:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68487 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68487-submit@debbugs.gnu.org id=B68487.171106651825547 (code B ref 68487); Fri, 22 Mar 2024 00:16:01 +0000 Original-Received: (at 68487) by debbugs.gnu.org; 22 Mar 2024 00:15:18 +0000 Original-Received: from localhost ([127.0.0.1]:48846 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rnSZ3-0006dz-Qy for submit@debbugs.gnu.org; Thu, 21 Mar 2024 20:15:18 -0400 Original-Received: from mail-qv1-f53.google.com ([209.85.219.53]:46491) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rnSZ1-0006db-DR for 68487@debbugs.gnu.org; Thu, 21 Mar 2024 20:15:16 -0400 Original-Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-68f41af71ebso12686136d6.1 for <68487@debbugs.gnu.org>; Thu, 21 Mar 2024 17:14:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martinmarshall-com.20230601.gappssmtp.com; s=20230601; t=1711066409; x=1711671209; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Pbete4xl1t/7pV3GKnXNOw/tg96D9nML6GEHZpy4jXg=; b=kPNzUC67dIFVteOu5D4ER7dbtZ0519Gr3QzSE3Rnw+CM+vBjZlE63eKU4/8iFprjrw PVEI7ynzuUManLe12FfEyTMFxWf0/xkpsJJyV4AmM7Pd3/ArQ0MbVZNF8dd46zIPituN VZ03wIkkdBeTQ3tjsSJtdv+H9zRq/AW95ET9+4TPWvm3SOm2fAFYOAXxwmHJQpEOWjk7 IbcEVnkWsdNSNjJeo6RNtkGBIW7ydcLxz4YNbMB0RnC3tudHCXQD0YgPVS5Z++J/mG0L wDFIneX0/oL4vFdOTzNzqydfkcu6fqCZn2WL3128JYoGymj/ZxexctPVnXlkMdPQRoM6 hapQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711066409; x=1711671209; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Pbete4xl1t/7pV3GKnXNOw/tg96D9nML6GEHZpy4jXg=; b=hUANV/7F1pUCrrA2JQsXImMbAXnyEYdSCUHSrsVJ5u8v3f0DqsKCoeqgIJWJyi0Ayv HRtGwwsfauwhyWNkWsBI8SH0WRiQcKJme47kvl3rXFgAtiHeYz/7elf8Rxwi3LVntFoa uYaOrB+AtmhcAUigznjIgJyhgiFl/lUGtV03vtbP8eADPXSq6mgVLIkIu6twjN2nybZx lV8ZMnfw9C7XTDeDA7VxJwXkJhD6yBv9ieaw85I2jE1SJgJLAh+yQH2JT8ketVySFfwt Am7eiFCBT3QVpqCzWtrJY2BeVOsC56sm+GyOyeoI2mkvFqGwa5Bq66YT1sOfjhV5bK29 ukxQ== X-Forwarded-Encrypted: i=1; AJvYcCWs77t8Hc0NyM9b3ROgIPKG3o1r9nOYPa7R8Hn2g8hszF7NsjTcJP1avjO+6a35SEZPDHZsvAiORJsjKehsDe38foGdu3Q= X-Gm-Message-State: AOJu0YzNpXMdiLyl31W47VeoB0gGBYWowG0ia9S31UBgrrvYsrmZrt6i 6Eo5x0XDuQ3Dc3o0B3kTYqNXTww2WW2TbEQljEuRSDagEgRFMnkhQIn/u/JguFmRGVPT6k5yOtc = X-Google-Smtp-Source: AGHT+IHI6PgSWSCTczHPhBNO3ipkQ0WpSIg9WPPx4zok5ZauDcnjTGcTPHgEdTQ9Fqo/kIMl7UFylA== X-Received: by 2002:a0d:d202:0:b0:60a:5031:2de9 with SMTP id u2-20020a0dd202000000b0060a50312de9mr799894ywd.51.1711065925534; Thu, 21 Mar 2024 17:05:25 -0700 (PDT) Original-Received: from vader (68-252-220-225.lightspeed.tukrga.sbcglobal.net. [68.252.220.225]) by smtp.gmail.com with ESMTPSA id gj6-20020a05690c428600b00610e03c9fe8sm157743ywb.103.2024.03.21.17.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 17:05:25 -0700 (PDT) In-Reply-To: <86o7bhb6ak.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Mar 2024 09:50:59 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:281919 Archived-At: Eli Zaretskii 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" >> >> >> 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