From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#71374: [PATCH] Simplify 'help-enable-variable-value-editing' using Date: Mon, 26 Aug 2024 20:27:38 +0000 Message-ID: <87ttf7do79.fsf@posteo.net> References: <87ikync1zh.fsf@posteo.net> <86frtrk2ec.fsf@gnu.org> <8734pqbneq.fsf@posteo.net> <871q3xklgv.fsf@jeremybryant.net> <87msm1pvsj.fsf@posteo.net> <87y152j6x5.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27396"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71374@debbugs.gnu.org To: Eshel Yaron Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 26 22:28:40 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 1sigKO-0006t7-6w for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 26 Aug 2024 22:28:40 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sigJx-0007OM-60; Mon, 26 Aug 2024 16:28:13 -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 1sigJv-0007O3-1V for bug-gnu-emacs@gnu.org; Mon, 26 Aug 2024 16:28:11 -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 1sigJu-0007Rw-O4 for bug-gnu-emacs@gnu.org; Mon, 26 Aug 2024 16:28:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=4/rOdDqGHZOpZWF9otgxq/PYDbXZ+3Dd8k+7vnSmOg8=; b=tcb0M0cxl1kmbmvvffEyUUBM02SQ4MHFeBuKa97aBvKsV6/7ZRj0bT/kiK7C1qnQxtngCcC3t6Jm5wfTubK+4sTgS3rYeZtf4In0CBIES3Nticqqkx2oGl+zrNL1FqPW4bJw4d9EBQKvBXc9r49iBylv4E2D8LrJje3f1XfHY+urZCxOj9dPXnQzCkUr/T6cWm3dce3ang1qZnK+XRVIK71tHWpXACNC+3f0IBVx5Sko6hedTd2Z9H8wfM8QhKtLM68RWQjVdoQqvLM3/+1QITuiq7GrKMtD4TZgm0EVKOL7C12XMsIDiTH33eoMLGoO+ljR0vbMgDGsmTfAxqT6qQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sigKj-0000T5-R8 for bug-gnu-emacs@gnu.org; Mon, 26 Aug 2024 16:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 26 Aug 2024 20:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71374 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71374-submit@debbugs.gnu.org id=B71374.17247041211765 (code B ref 71374); Mon, 26 Aug 2024 20:29:01 +0000 Original-Received: (at 71374) by debbugs.gnu.org; 26 Aug 2024 20:28:41 +0000 Original-Received: from localhost ([127.0.0.1]:45277 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sigKO-0000SP-RP for submit@debbugs.gnu.org; Mon, 26 Aug 2024 16:28:41 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:58097) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sigKM-0000SB-5J for 71374@debbugs.gnu.org; Mon, 26 Aug 2024 16:28:39 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 90B42240029 for <71374@debbugs.gnu.org>; Mon, 26 Aug 2024 22:27:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1724704059; bh=6iWrFxS4IiuUYznExZdBw7k21baaI3OJ5p3bVVGi9cA=; h=From:To:Cc:Subject:Autocrypt:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=Omo8z03ltkg3aiQX4HZmzAnAn9WWzVfWhTOOKZhltWbBKk3RVd6tA+vgtEW7K+MAK Cj2Ruw1vrnlFKCdP04fziwAlBYzazigped7tAabR6LXYSZ38fae8knHhQWiLAmOJ+q Z8v/ng+pscoY4a10YnQ2lq/MqqFO2cZWoPtw0M2VMgqRwCbVsJN3uNhx8S4T+0PDWW C4p3jLYlSCK0uwc21zK5/rUota4Vcq4KvH8+amMWcCHdJzCIt5zIppCi5hfS0dCfkc 3qxezWq8lXe/pTQKT8e9ShHfH75+yXluy5eRyAVqrJZuEJtzo0Pv3XO+5i6ujQV8p1 Ao+PVd/DjAURw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Wt2Kk6Pkdz6twG; Mon, 26 Aug 2024 22:27:38 +0200 (CEST) In-Reply-To: (Eshel Yaron's message of "Tue, 13 Aug 2024 07:59:00 +0200") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt 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:290793 Archived-At: --=-=-= Content-Type: text/plain Eshel Yaron writes: > Philip Kaludercic writes: > >> Eshel Yaron writes: >> >>> I'm reopening this (hope you don't mind) to keep track of the minor >>> regressions I mentioned here: >>> >>> https://lists.gnu.org/archive/html/emacs-devel/2024-07/msg01202.html >> >> Thanks, and my apologies for the late reply. > > No problem at all. > >> The issue seems to be that (thing-at-point 'sexp) returns nil if inside >> a s-expression looking at whitespace: >> >> (1 2 3 4 5) >> ^ >> M-: (thing-at-point 'sexp) ;=> nil >> >> One idea is to fall back on a defun at point, if no sexp is found: >> >> diff --git a/lisp/help-fns.el b/lisp/help-fns.el >> index 8ea5b301684..4d55ea8bbff 100644 >> --- a/lisp/help-fns.el >> +++ b/lisp/help-fns.el >> @@ -1507,13 +1507,14 @@ help-fns-edit-variable >> "Edit the variable under point." >> (declare (completion ignore)) >> (interactive) >> - (let* ((val (thing-at-point 'sexp)) >> - (var (get-text-property 0 'help-fns--edit-variable val))) >> + (let ((val (or (thing-at-point 'sexp) >> + (thing-at-point 'defun)))) >> (unless val >> - (error "No variable under point")) >> - (let ((str (read-string-from-buffer >> - (format ";; Edit the `%s' variable." (nth 0 var)) >> - (prin1-to-string (nth 1 var))))) >> + (error "No value at point")) >> + (let* ((var (get-text-property 0 'help-fns--edit-variable val)) >> + (str (read-string-from-buffer >> + (format ";; Edit the `%s' variable." (nth 0 var)) >> + (prin1-to-string (nth 1 var))))) >> (set (nth 0 var) (read str))))) > > Maybe I'm missing something, but why are val and the thing-at-point call > needed at all? Simply grabbing the help-fns--edit-variable property at > point should be work as well, I think. No, I think you are right, we don't have to take the detour over 'thing-at-point', meaning that if I am not mistaken, the fix should reduce itself to: --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 8a2ae79736f..97d054ce6db 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -1507,9 +1507,8 @@ help-fns-edit-variable "Edit the variable under point." (declare (completion ignore)) (interactive) - (let* ((val (thing-at-point 'sexp)) - (var (get-text-property 0 'help-fns--edit-variable val))) - (unless val + (let ((var (get-text-property (point) 'help-fns--edit-variable))) + (unless var (error "No variable under point")) (let ((str (read-string-from-buffer (format ";; Edit the `%s' variable." (nth 0 var)) --=-=-= Content-Type: text/plain > Eshel -- Philip Kaludercic on peregrine --=-=-=--