From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pierre Rouleau Newsgroups: gmane.emacs.bugs Subject: bug#44494: etags.el xref-location-marker does not handle TAGS references to .el.gz files Date: Fri, 6 Nov 2020 18:22:46 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000002b5d5505b3787e54" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36583"; mail-complaints-to="usenet@ciao.gmane.io" To: 44494@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 07 00:24:11 2020 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 1kbB5W-0009Oy-ND for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 07 Nov 2020 00:24:10 +0100 Original-Received: from localhost ([::1]:49250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbB5V-0001H4-9F for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 06 Nov 2020 18:24:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbB5O-0001Gr-L9 for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2020 18:24:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46042) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kbB5O-0001LG-BY for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2020 18:24:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kbB5O-0004WH-8X for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2020 18:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Pierre Rouleau Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Nov 2020 23:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 44494 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.160470498617306 (code B ref -1); Fri, 06 Nov 2020 23:24:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Nov 2020 23:23:06 +0000 Original-Received: from localhost ([127.0.0.1]:57588 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kbB4U-0004V4-3R for submit@debbugs.gnu.org; Fri, 06 Nov 2020 18:23:06 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:37918) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kbB4T-0004Ux-5n for submit@debbugs.gnu.org; Fri, 06 Nov 2020 18:23:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbB4S-00016P-W3 for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2020 18:23:05 -0500 Original-Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:37887) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kbB4P-00016V-AM for bug-gnu-emacs@gnu.org; Fri, 06 Nov 2020 18:23:04 -0500 Original-Received: by mail-wr1-x429.google.com with SMTP id w1so2947306wrm.4 for ; Fri, 06 Nov 2020 15:22:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=eVqDBdfsSRl1uB9eBrmghhoiN0DWZyzgA2lBOrA/5+A=; b=R79MybzYoGlX8J4eEs9lYDWRBxUw1DzaoQXVBsC63qSNf0d3XyXApUWMsGxHxrVHZk WET8pvzb9CcAofmd3QzFcYvOqD215iBdW55HE7sJIcRrbSewsgsHSfaylENR8xuJ9Pg/ b+w5zHBm3xauiOPpKLEB1dURR6fDavCfFF+Wu+AQ64gAG54CIOTdGOqbJ33qDacZz1sO myOBFkOujSUgBATOyezx9ONYj+upsV/Pog6id4QrLunvuftyoFZ98kc0/9Zv7z8WtuTJ 22llo2h5QuhRxcqPx4r36R2x6R4H1Ins3FM4QQTFRROf0es44XPw2lrYsExqj97Qwje6 1wGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=eVqDBdfsSRl1uB9eBrmghhoiN0DWZyzgA2lBOrA/5+A=; b=rWpYbmhdK0I85O1q5xM7jskauTxVDUexOhvhltk7XXkrK6Kugk5N8y/6XRV6xHzGGo 206Nnzh8AVW/R1Ta0FNRl0XVCJOCEjjini/smjT2GhViKzZCtaonyCgnocBtfXr5+8qC VnhG/Dashj+vfYIXi6EefszJZpyIFqSkBLsTfV0VJmO47hufLWx/I1/cpAuFxHII04m3 xKSQDszOqSHOFPSlQwCX2HKjOIhhxjnQrVv4yQiu57oeAAlVYixuevzD3c03KptD1Dan RXDTSFXJA5Y5PBL8PkXx6T9iX9d1kC2MQKjSW6uyQxxstSacZKIwn/JdOAPO8enng/BL +/MQ== X-Gm-Message-State: AOAM531reZ6CVVdTDVysCRXin3I86WALrURpkPKohaqhCzdI5jslQTY2 2IhFynSShnHYZh2EGf5JILvT0i+saStJnKZ/TwTBNJqDHQw= X-Google-Smtp-Source: ABdhPJwkLYTrIXaM4n9xgaPzUoPIxKVX9nEgtv75zz9BzhwbPnAxVC4TVQAZ29OUuoqVKuml/WZ+Kx21TlWgbA4BVxw= X-Received: by 2002:a5d:4104:: with SMTP id l4mr3619002wrp.276.1604704977770; Fri, 06 Nov 2020 15:22:57 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=prouleau001@gmail.com; helo=mail-wr1-x429.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, HTML_MESSAGE=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: 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" Xref: news.gmane.io gmane.emacs.bugs:192805 Archived-At: --0000000000002b5d5505b3787e54 Content-Type: text/plain; charset="UTF-8" This problem was detected in emacs 26.3, but is also present in emacs 27.1, according to the code posted inside https://github.com/emacs-mirror/emacs/blob/master/test/manual/etags/el-src/emacs/lisp/progmodes/etags.el#L2139 Problem description follows: ----------------------------BUG DESCRIPTION [ ------------------------------ The current version of etags distributed with emacs 27.0 is capable of parsing compressed files like something.el.gz but unfortunately the reference inside the generated TAGS file uses the name "something.el" instead of the complete file name "something.el.gz". The same is true for the other compressed files (.bz2, .xz and .lzma). When trying to use the etags xref back-end to move point to a definition inside such a file, the xref-find-definitions command will fail because the TAGS file identifies the .el file instead of the .el.gz file. xref-find-definitions fails because it only checks if the uncompressed file exists, it does not try to see if the compressed file exists. The issue is inside etags.el xref-location-marker method. The current code is: (cl-defmethod xref-location-marker ((l xref-etags-location)) (with-slots (tag-info file) l (let ((buffer (find-file-noselect file))) (with-current-buffer buffer (save-excursion (etags-goto-tag-location tag-info) (point-marker)))))) One could consider that the issue is inside the etags utility. An alternative would be to provide Emacs with the ability to check for the presence of the .el file and if it is not present look for the equivalent compressed files. Here's a proposal for a solution: (defun etags-file-or-compressed-file-for (fname) "Return the valid file name for FNAME. Check if FNAME is an existing file name, if not try FNAME appended with the following compression extensions: - \".gz\", the extension of compressed files created by gzip - \".bz2\", the extension for compressed files created by bzip2 - \".xz\", the extension for compressed files created by xz - \".lzma\", the extension for compressed files created by xz. Return the file that exists or nil if nothing found." (let ((fpath nil)) (cl-dolist (ext '("" ".gz" ".bz2" ".xz" ".lzma")) (setq fpath (concat fname ext)) (when (file-exists-p fpath) (cl-return fpath))))) (cl-defmethod xref-location-marker ((l xref-etags-location)) (with-slots (tag-info file) l (let (buffer (fname (pel-file-or-compressed-file-for file))) (if fname (setq buffer (find-file-noselect fname)) (user-error "file %s (or .gz, .bz2, .xz, .lzma) does not exist" file)) (with-current-buffer buffer (save-excursion (etags-goto-tag-location tag-info) (point-marker)))))) ------------------------------ END OF DESCRIPTION ] -------------------------------- In GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.6.0) of 2019-08-30 built on Mojave.local Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Configured using: 'configure --disable-dependency-tracking --disable-silent-rules --enable-locallisppath=/usr/local/share/emacs/site-lisp --infodir=/usr/local/Cellar/emacs/26.3/share/info/emacs --prefix=/usr/local/Cellar/emacs/26.3 --with-gnutls --without-x --with-xml2 --without-dbus --with-modules --without-ns --without-imagemagick' Configured features: NOTIFY ACL GNUTLS LIBXML2 ZLIB MODULES THREADS Important settings: value of $LANG: en_CA.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config gnus-util rmail tool-bar rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail regexp-opt rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils term/xterm xterm time-date elec-pair mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads kqueue multi-tty make-network-process emacs) Memory information: ((conses 16 96177 5831) (symbols 48 19813 1) (miscs 40 33 96) (strings 32 28253 1011) (string-bytes 1 748198) (vectors 16 11977) (vector-slots 8 455846 6474) (floats 8 48 566) (intervals 56 197 0) (buffers 992 11)) ;; --------------------------- Thank you, /Pierre Rouleau --0000000000002b5d5505b3787e54 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This problem was detected in emacs 26.3, but is also = present in emacs 27.1, according to the code posted inside https://github.com/emacs-mirror/emacs/blob/= master/test/manual/etags/el-src/emacs/lisp/progmodes/etags.el#L2139

Problem description follows:

=


----------------------------BUG DESCRIPT= ION [ ------------------------------

The curre= nt version of etags distributed with emacs 27.0 is capable of
parsing = compressed files like something.el.gz but unfortunately the
reference in= side the generated TAGS file uses the name "something.el"
inst= ead of the complete file name "something.el.gz".=C2=A0 The same i= s true
for the other compressed files (.bz2, .xz and .lzma).

When= trying to use the etags xref back-end to move point to a definition
inside such a file, the xref-find-definitions command will fail because t= he
TAGS file identifies the .el file instead of the .el.gz file.=

xref-find-definitions fails because it only checks if = the uncompressed
file exists, it does not try to see if the compres= sed file exists.

The issue is inside etags.el xref-loca= tion-marker method.

The current code is:

(cl-defmethod xref-l= ocation-marker ((l xref-etags-location))
=C2=A0 (with-slots (tag-info fi= le) l
=C2=A0 =C2=A0 (let ((buffer (find-file-noselect file)))
=C2=A0 = =C2=A0 =C2=A0 (with-current-buffer buffer
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (s= ave-excursion
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (etags-goto-tag-locatio= n tag-info)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (point-marker))))))<= /div>

One could consider that the issue is inside t= he etags utility.

An alternative would be to provi= de Emacs with the ability to check
for the presence of the .= el file and if it is not present look for the
equivalent com= pressed files.

Here's a proposal for a solution:

=
(defun etags-file-or-compressed-file-for (fname)
=C2=A0 "Return= the valid file name for FNAME.
Check if FNAME is an existing file name,= if not
try FNAME appended with the following compression extensions:- \".gz\", the extension of compressed files created by gzip
= - \".bz2\", the extension for compressed files created by bzip2- \".xz\", the extension for compressed files created by xz
= - \".lzma\", the extension for compressed files created by xz.
Return the file that exists or nil if nothing found."
=C2=A0 (= let ((fpath nil))
=C2=A0 =C2=A0 (cl-dolist (ext '(""
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ".gz"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 ".bz2"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ".xz"
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "= ;.lzma"))
=C2=A0 =C2=A0 =C2=A0 (setq fpath (concat fname ext))
= =C2=A0 =C2=A0 =C2=A0 (when (file-exists-p fpath)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 (cl-return fpath)))))

(cl-defmethod xref-location-marker ((l = xref-etags-location))
=C2=A0 (with-slots (tag-info file) l
=C2=A0 =C2= =A0 (let (buffer
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (fname (pel-file-or-= compressed-file-for file)))
=C2=A0 =C2=A0 =C2=A0 (if fname
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (setq buffer (find-file-noselect fname))
=C2=A0= =C2=A0 =C2=A0 =C2=A0 (user-error "file %s (or .gz, .bz2, .xz, .lzma) = does not exist" file))
=C2=A0 =C2=A0 =C2=A0 (with-current-buffer bu= ffer
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (save-excursion
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 (etags-goto-tag-location tag-info)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 (point-marker))))))

------------------= ------------ END OF DESCRIPTION ] --------------------------------


In GNU Emacs 26.3 (build 1, x86_64-apple-dar= win18.6.0)
=C2=A0of 2019-08-30 built on Mojave.local
Recent messages:=
For information about GNU Emacs and the GNU system, type C-h C-a.
Configured using:
=C2=A0'configure --disable-dependency-tracking -= -disable-silent-rules
=C2=A0--enable-locallisppath=3D/usr/local/share/em= acs/site-lisp
=C2=A0--infodir=3D/usr/local/Cellar/emacs/26.3/share/info/= emacs
=C2=A0--prefix=3D/usr/local/Cellar/emacs/26.3 --with-gnutls --with= out-x
=C2=A0--with-xml2 --without-dbus --with-modules --without-ns
= =C2=A0--without-imagemagick'

Configured features:
NOTIFY ACL = GNUTLS LIBXML2 ZLIB MODULES THREADS

Important settings:
=C2=A0 va= lue of $LANG: en_CA.UTF-8
=C2=A0 locale-coding-system: utf-8-unix
Major mode: Lisp Interaction

Minor modes in effect:
=C2=A0 toolt= ip-mode: t
=C2=A0 global-eldoc-mode: t
=C2=A0 eldoc-mode: t
=C2=A0= electric-indent-mode: t
=C2=A0 menu-bar-mode: t
=C2=A0 file-name-sha= dow-mode: t
=C2=A0 global-font-lock-mode: t
=C2=A0 font-lock-mode: t<= br>=C2=A0 auto-composition-mode: t
=C2=A0 auto-encryption-mode: t
=C2= =A0 auto-compression-mode: t
=C2=A0 line-number-mode: t
=C2=A0 transi= ent-mark-mode: t

Load-path shadows:
None found.

Features:<= br>(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
byte= comp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs
format-s= pec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-confi= g gnus-util rmail tool-bar rmail-loaddefs mm-decode mm-bodies
mm-encode = mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
regexp-opt r= fc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
term/xterm xterm= time-date elec-pair mule-util tooltip eldoc electric
uniquify ediff-hoo= k vc-hooks lisp-float-type tabulated-list replace
newcomment text-mode e= lisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow isearch= timer select mouse jit-lock font-lock
syntax facemenu font-core term/tt= y-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese = tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek = romanian slovak czech european
ethiopic indian cyrillic chinese composit= e charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbr= ev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-fac= e macroexp files
text-properties overlay sha1 md5 base64 format env code= -pages mule
custom widget hashtable-print-readable backquote threads kqu= eue
multi-tty make-network-process emacs)

Memory information:
= ((conses 16 96177 5831)
=C2=A0(symbols 48 19813 1)
=C2=A0(miscs 40 33= 96)
=C2=A0(strings 32 28253 1011)
=C2=A0(string-bytes 1 748198)
= =C2=A0(vectors 16 11977)
=C2=A0(vector-slots 8 455846 6474)
=C2=A0(fl= oats 8 48 566)
=C2=A0(intervals 56 197 0)
=C2=A0(buffers 992 11)= )

;; ---------------------------

Thank you,

/Pierre Rouleau
--0000000000002b5d5505b3787e54--