From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#68487: [PATCH] Make jump commands usable for all skeletons Date: Sat, 02 Mar 2024 23:07:18 -0500 Message-ID: References: <877ckawckc.fsf@martinmarshall.com> <875xz2y46o.fsf@martinmarshall.com> <87il316y4w.fsf@martinmarshall.com> <875xycyq0x.fsf@martinmarshall.com> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31672"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 68487@debbugs.gnu.org To: Martin Marshall Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 03 05:09:11 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 1rgd9z-00085M-Di for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 Mar 2024 05:09:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rgd9O-0002YB-SA; Sat, 02 Mar 2024 23:08:34 -0500 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 1rgd9N-0002Y1-NW for bug-gnu-emacs@gnu.org; Sat, 02 Mar 2024 23:08:33 -0500 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 1rgd9N-0002L9-Es for bug-gnu-emacs@gnu.org; Sat, 02 Mar 2024 23:08:33 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rgd9q-0004cH-4w for bug-gnu-emacs@gnu.org; Sat, 02 Mar 2024 23:09:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Mar 2024 04:09:02 +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.170943888417667 (code B ref 68487); Sun, 03 Mar 2024 04:09:02 +0000 Original-Received: (at 68487) by debbugs.gnu.org; 3 Mar 2024 04:08:04 +0000 Original-Received: from localhost ([127.0.0.1]:39542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rgd8u-0004at-CR for submit@debbugs.gnu.org; Sat, 02 Mar 2024 23:08:04 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:53620) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rgd8q-0004aM-VV for 68487@debbugs.gnu.org; Sat, 02 Mar 2024 23:08:02 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C58E480AD4; Sat, 2 Mar 2024 23:07:25 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1709438840; bh=aCtZutSPBZrt2NVcGWjTNCm5zUbEg2k/SpFU5YrIayc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=mM1lpAR9g9ThCldPrBycl7x5hYZlCSnjaV4WEdWzY7mRnckPFYnxEVbGpOZ7ruSQm HH56Dj14gMf4rHYgqbQKNFPNcKtN0lhH4Zs6M2BW5zL0Xpk0CFn2uKZg0bVuTTwJi2 roy5vGeJSjDOHDqnqRBt+s/pY7m9qj/8EhRLL7tErJJKm6ataGW46qjc96nNaZwGHW ITisr9dzj2Uh1l+dOt1qoXSGKPc2kc69X4WpCbIo7QduRTRSN/I+IXqg4bLO1Rf8yS QfAZQnaEcVEBxymKk0DW4FqVl6vv2ne+r5FYYwXIR2IUAYppkx+nGTSr2hnjFJCnGb r+4jWQSItwI3Q== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 7284D804BC; Sat, 2 Mar 2024 23:07:20 -0500 (EST) Original-Received: from pastel (unknown [216.154.1.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4B3B6120749; Sat, 2 Mar 2024 23:07:20 -0500 (EST) In-Reply-To: <875xycyq0x.fsf@martinmarshall.com> (Martin Marshall's message of "Sun, 25 Feb 2024 20:26:22 -0500") 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:280916 Archived-At: >> 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