From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Hong Xu Newsgroups: gmane.emacs.bugs Subject: bug#37611: [PATCH] Default FILE to the current buffer for list-tags Date: Thu, 3 Oct 2019 19:05:08 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="40400"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 To: 37611@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 04 04:06:26 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iGCzC-000AQ6-3e for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Oct 2019 04:06:26 +0200 Original-Received: from localhost ([::1]:41778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGCzA-0002em-Vn for geb-bug-gnu-emacs@m.gmane.org; Thu, 03 Oct 2019 22:06:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33327) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGCyr-0002eV-Q4 for bug-gnu-emacs@gnu.org; Thu, 03 Oct 2019 22:06:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGCyq-0006RP-0x for bug-gnu-emacs@gnu.org; Thu, 03 Oct 2019 22:06:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60922) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iGCyp-0006R9-RY for bug-gnu-emacs@gnu.org; Thu, 03 Oct 2019 22:06:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iGCyp-0002Cd-Ht for bug-gnu-emacs@gnu.org; Thu, 03 Oct 2019 22:06:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Hong Xu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Oct 2019 02:06:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 37611 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.15701547288406 (code B ref -1); Fri, 04 Oct 2019 02:06:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Oct 2019 02:05:28 +0000 Original-Received: from localhost ([127.0.0.1]:41508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iGCyF-0002BU-OM for submit@debbugs.gnu.org; Thu, 03 Oct 2019 22:05:27 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:43709) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iGCyD-0002BJ-6O for submit@debbugs.gnu.org; Thu, 03 Oct 2019 22:05:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33138) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGCyC-0002bY-2d for bug-gnu-emacs@gnu.org; Thu, 03 Oct 2019 22:05:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGCyA-0005hp-LP for bug-gnu-emacs@gnu.org; Thu, 03 Oct 2019 22:05:23 -0400 Original-Received: from sender4-of-o54.zoho.com ([136.143.188.54]:21415) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iGCyA-0005dW-An for bug-gnu-emacs@gnu.org; Thu, 03 Oct 2019 22:05:22 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1570154711; cv=none; d=zoho.com; s=zohoarc; b=aXqO4O5Pj3Nz/1rKgPpB7N84kvS4NUEzk6E739+yKWSOrslUzt5pY2/9tlxtok77c7pB75YfYi5NGWRnXNx9txFtvZ39aO311dXM6+qIebjyLsnpV0mF5IDWun+u42sjPyzDiE2mbiwfbyU2Xd6454xsLSG+8aLS1utuIh5oQT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570154711; h=Content-Type:Content-Transfer-Encoding:Date:From:MIME-Version:Message-ID:Subject:To:ARC-Authentication-Results; bh=fyJN0D+6rwjn6wqF9mc5jZfUoCbmXbzpkkTqY8ezKZA=; b=jOgeFGf9cpHC2k+3ht0C5+3lZfXkb98L0Dlz2+Ir7wPILrc2ka/S2PReB7jAeIjcWbe3t5BBkfvVKVMwGaBqO2p3Pf+aoBfWfuoSnsPY24FzitubIyanGMbFbVkQ+7TdZdnydfWlM29Nb82iD0ZqF66+Etbi4sl/YkBwnLB8O7k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=topbug.net; spf=pass smtp.mailfrom=hong@topbug.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1570154711; s=zoho; d=topbug.net; i=hong@topbug.net; h=To:From:Subject:Message-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1685; bh=fyJN0D+6rwjn6wqF9mc5jZfUoCbmXbzpkkTqY8ezKZA=; b=EjHpiuRZs+m0AfjOltYYz8CA9l1SC3u7ubPVX6rKjmNIqUf7jWtuMhAMzoYZbR9z H6umPKozITUla2wS7tJ0lq3708Tx6PxLhzNj0TfUDncGcJPoFewowBtw8Gj8Olvp4dd ACqoJeuYC+9tYaFVn8/6e67wXepXZiSQucHS5Ctc= Original-Received: from [192.168.88.88] (69-215-149-151.lightspeed.sntcca.sbcglobal.net [69.215.149.151]) by mx.zohomail.com with SMTPS id 157015470915531.406218531986497; Thu, 3 Oct 2019 19:05:09 -0700 (PDT) Openpgp: preference=signencrypt Content-Language: en-US X-ZohoMailClient: External X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:168299 Archived-At: * lisp/progmodes/etags.el (list-tags) (tags--get-current-buffer-name-in-tags-file): Default FILE to the current buffer for list-tags. --- lisp/progmodes/etags.el | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index a03516100087..23acffcac299 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el @@ -1852,15 +1852,27 @@ tags-complete-tags-table-file (all-completions string (tags-table-files) predicate) (try-completion string (tags-table-files) predicate)))) +(defun tags--get-current-buffer-name-in-tags-file () + "Get the file name that the current buffer corresponds in the tags file." + (let ((tag-dir + (save-excursion + (visit-tags-table-buffer) + (file-name-directory (buffer-file-name))))) + (when (string-prefix-p tag-dir (buffer-file-name)) + (substring (buffer-file-name) (length tag-dir) nil)))) + ;;;###autoload (defun list-tags (file &optional _next-match) "Display list of tags in file FILE. This searches only the first table in the list, and no included tables. FILE should be as it appeared in the `etags' command, usually without a directory specification." - (interactive (list (completing-read "List tags in file: " - 'tags-complete-tags-table-file - nil t nil))) + (interactive (list (completing-read + "List tags in file: " + 'tags-complete-tags-table-file + nil t + ;; Default FILE to the current buffer. + (tags--get-current-buffer-name-in-tags-file)))) (with-output-to-temp-buffer "*Tags List*" (princ (substitute-command-keys "Tags in file `")) (tags-with-face 'highlight (princ file)) -- 2.18.1