From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.devel Subject: Re: Patch proposal: display symbol source code in help buffers Date: Tue, 21 Sep 2021 17:17:19 +0800 Message-ID: <87r1diqodc.fsf@localhost> References: <875yuvlrz3.fsf@gnus.org> <87r1djixiw.fsf@gnus.org> <878rzrzpfz.fsf@localhost> <87zgs7y5wc.fsf@localhost> <87sfxyftrw.fsf@gnus.org> <87mto6ifd2.fsf@localhost> <83r1diz5k9.fsf@gnu.org> 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="3260"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, Stefan Kangas , arthur.miller@live.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 21 11:17:16 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mSbts-0000a2-26 for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Sep 2021 11:17:16 +0200 Original-Received: from localhost ([::1]:51394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSbtq-0003jl-Km for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Sep 2021 05:17:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSbsm-0002WE-VP for emacs-devel@gnu.org; Tue, 21 Sep 2021 05:16:08 -0400 Original-Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:43904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mSbsl-0005gw-6R; Tue, 21 Sep 2021 05:16:08 -0400 Original-Received: by mail-pj1-x102e.google.com with SMTP id k23-20020a17090a591700b001976d2db364so2059852pji.2; Tue, 21 Sep 2021 02:16:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=fbE7SRD1mPecU5x2lUFbm5st2N76vWD0y/6E3ffqLEY=; b=ByLwXbpCy/4NPfpJhHq2mWK6pSNiuAwyy9lRjI7w4cTm8LCCLdipE6RU2QMR8hEAre c/YAjBn8GNLAVg6OaSflCgSnHULwvoZE7OGZdJuLpUEtgbXV20ahlenbvcyibdiX/pLR h84kTu83lZ8n3kGxz7IVp48vdjccS+eHZf/xndQw26dAr2zRrwygsoHtYjykJP0PTJLx eeJaWUhBnEbC4ZF+9ZillncCQo6c+EESQa0coVtRfMIimPlt35jhFkEDT5asc02Myn6s KvYHmzS1XCmk/M3qnUYJO66XhnhkrcjBKVZHpeszujCZc/+5HD9y9ixZ/cjG/KCo0yqN UYtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=fbE7SRD1mPecU5x2lUFbm5st2N76vWD0y/6E3ffqLEY=; b=7y7lqU7+zPIcMQRd+0me08puRc6Z4aRCTdEvMaCncI7qKyFv+efujjDb+a91Y5CriG FUiF9YaJaDhz7RjmyKgaUfVOCIGEDFhXs1tOOWtZh+DXncGodMqJsdM4tmkMEish1pZj lCYIoLaSyGgVuLECX9RgT+fZIKYVyW26GXw/mau8mkPLVtmijvEkk9H+08XyvZXyXA/V BjZLxt3fP4VI3P2s+stYs+kamiMqfG+afxyLhqMpnWt1+ut7Z80MRuasRK0ngTgKM2pu Qs6b7r/93BDn0sREaYuwIecp71r924bBtH3RUPpn2eREn3xeP67mU3A1uyKNVOqp+hj8 fQRg== X-Gm-Message-State: AOAM5338dh9Nyj8Se2VzbnaXfeRaqouca3j+3cCoHeKDTFi3XoXJuFu3 K/te5lVfC9UpjK73xzilvTfMHJvUXLT2C3cuU8E= X-Google-Smtp-Source: ABdhPJx9Cq/pOj+7Ne/0Lb90QmyerJ2GoICqW6+0TC8tmkInCfU7SM1b3ZCKqXVt8MshEA/u3GsRog== X-Received: by 2002:a17:903:246:b0:13a:22d1:88b with SMTP id j6-20020a170903024600b0013a22d1088bmr26872182plh.16.1632215764413; Tue, 21 Sep 2021 02:16:04 -0700 (PDT) Original-Received: from localhost ([160.202.160.104]) by smtp.gmail.com with ESMTPSA id y126sm16712312pfy.88.2021.09.21.02.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 02:16:03 -0700 (PDT) In-Reply-To: <83r1diz5k9.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=yantar92@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:275211 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Ihor Radchenko writes: >> >> > I like this idea. Maybe we can simply change the default value of >> > find-function-after-hook like in the attached patch? >> >> We generally prefer not to add hooks like this if we can avoid it. We >> can usually just change the code instead. >> >> For example, in this case maybe we could just call `push-mark' at the >> end of `help-function-def--button-function'. > > Indeed, especially since the proposed change to find-func.el would > affect all users of that package. Agree. I updated the patch and also added support for widen-automatically variable. See below. Best, Ihor --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Save-position-in-mark-ring-before-jumping-to-definit.patch >From e94ae3711796679e330637921b980f970b9d7025 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Tue, 21 Sep 2021 17:00:50 +0800 Subject: [PATCH 1/2] Save position in mark ring before jumping to definition * lisp/help-mode.el (help-function-def--button-function): Current point is saved in the mark ring before jumping to definition. Following up: https://lists.gnu.org/archive/html/emacs-devel/2021-09/msg01561.html --- etc/NEWS | 3 +++ lisp/help-mode.el | 1 + 2 files changed, 4 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 2bdcb6434b..2132e8babc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -648,7 +648,10 @@ clicking the "X" icon in the tool bar. --- *** 'g' ('revert-buffer') in 'help-mode' no longer requires confirmation. +*** Jumping to function/variable source now saves mark before moving point +Jumping to source from "*Help*" buffer moves the point when the source buffer is already open. Now, the old point is pushed to mark ring. +--- ** File Locks +++ diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 551cf7e1a3..57655db337 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -268,6 +268,7 @@ help-function-def--button-function (when (or (< position (point-min)) (> position (point-max))) (widen)) + (push-mark nil t) (goto-char position)) (message "Unable to find location in file"))))) -- 2.32.0 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-Honor-widen-automatically-in-help-function-def-butto.patch >From 109bd7192b5b672508b9fa1d53c10a5a8aec3846 Mon Sep 17 00:00:00 2001 Message-Id: <109bd7192b5b672508b9fa1d53c10a5a8aec3846.1632215537.git.yantar92@gmail.com> In-Reply-To: References: From: Ihor Radchenko Date: Tue, 21 Sep 2021 17:10:10 +0800 Subject: [PATCH 2/2] Honor widen-automatically in help-function-def--button-function * lisp/help-mode.el (help-function-def--button-function): Ask user to widen the buffer when `widen-automatically' is set to nil. --- lisp/help-mode.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 57655db337..5d566ca083 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -263,11 +263,14 @@ help-function-def--button-function (pop-to-buffer (car location)) (run-hooks 'find-function-after-hook) (if position - (progn + (catch :exit ;; Widen the buffer if necessary to go to this position. (when (or (< position (point-min)) (> position (point-max))) - (widen)) + (if (or widen-automatically + (yes-or-no-p "The location is outside narrowing. Widen? ")) + (widen) + (throw :exit nil))) (push-mark nil t) (goto-char position)) (message "Unable to find location in file"))))) -- 2.32.0 --=-=-=--