From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id YBXkFDW8xmV7ygAA62LTzQ:P1 (envelope-from ) for ; Sat, 10 Feb 2024 00:58:45 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id YBXkFDW8xmV7ygAA62LTzQ (envelope-from ) for ; Sat, 10 Feb 2024 00:58:45 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=martinmarshall-com.20230601.gappssmtp.com header.s=20230601 header.b=ElRqR8Ov; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1707523125; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=VkrNB7JEzXdoEbSulm434e1jko+N9zy2jLeHax7CmMg=; b=smJcMno4/VE8J+iZpH5/nq7dhRQIJyW3lU9Rix5YXjOwuIU6cgjX9UNTf95pGdUk1LJzZ0 t0wkZN0qpaVq9tPOWYPA+gympuMmQSEbqa2TrqYi+5zhYJVL8caLmuD02hvEuM9c53JQOJ DZ6/NliSeIWwvHILDU6MzlcidxnBJv3t3PpCavkmdPcqIgvhgdEYQqpn5tP1wfXVunA24/ U9mOsbeLPQoTPepKnHurItyv6+rhzb9LYleWpSRkYiNP06cAi+8xwzTY9uF/odVbj2jWjA NuZfcqWElX02ga2EbTgcN3Bf2pQAWMkUV3w7alVbiOf55foRS4Rl4d2qLF7fow== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=martinmarshall-com.20230601.gappssmtp.com header.s=20230601 header.b=ElRqR8Ov; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1707523125; a=rsa-sha256; cv=none; b=b6IDdZsIiQm0ZwIQDhfljsOYeoQHA7XDrupjAt3FFpXviLKlsNYUlFDQJt4xUbrE0oLFM0 wzws8nAFhHozMZAhpQr3vjwoMMOdRHGXwDVjj6wDOA3eEeGcZWoaW5zzTPVid4ByNHY0SZ PMHiHI3QpYfbLh7vvAKPZ/dPjvaT8b2/jJ2LU3PuGKZis7UJMEGZODtANKHeAUQ8Oj3fkU WeXhntCoUfclKDaRKVCk+0pVRXq157vCTswzPKqyH7LfhpKMzjMlA9G+QZzAc/HlEohKfn VrNIaHmDzXAPy6PJtM8OJuEfdkCUh9fteYjb4ifhuD5D2lu5nNhPDABxCHIX6w== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D035D5BE6C for ; Sat, 10 Feb 2024 00:58:44 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYakk-0003EX-6W; Fri, 09 Feb 2024 18:57:54 -0500 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 1rYakj-0003Dq-9d for emacs-orgmode@gnu.org; Fri, 09 Feb 2024 18:57:53 -0500 Received: from mail-yw1-x112d.google.com ([2607:f8b0:4864:20::112d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rYakh-0005IR-Iv for emacs-orgmode@gnu.org; Fri, 09 Feb 2024 18:57:53 -0500 Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-604a1581cffso15606027b3.3 for ; Fri, 09 Feb 2024 15:57:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martinmarshall-com.20230601.gappssmtp.com; s=20230601; t=1707523070; x=1708127870; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=VkrNB7JEzXdoEbSulm434e1jko+N9zy2jLeHax7CmMg=; b=ElRqR8Ovewr8G5oSiajKP4rHiwvb5YMF+VNccMXVVI4b9OYfGPwlAluiGbdxj2jlv0 xIHnqi7BrVFinUbYBTubBzMR6yJpk+voRN+FKr4zzT63ageCSM85oi7Qm/zPqOrljCgT OPZ7e3s/bDDDZdvPmoZ4y8amNDZTiF7/0ENGBnvT41hDNAXDZvv5UJzy8fdI99uI0yLN Iw1LlW3mA4VHOYuMI340tI2Ifph1jvuBy0L7Vyxvb9U/zs5Oca9VOh3l/N/GFQBsEkb1 2pEwG9MmfJlYKL5gOQvds9qUnCO/SCTjA/iTqhPcHqp2U8nxzVl+IllHQ0HOIYJHXy98 q7Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707523070; x=1708127870; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=VkrNB7JEzXdoEbSulm434e1jko+N9zy2jLeHax7CmMg=; b=XnnwXT2ql7PubXiaJBXRUsQcf6dxjKnLLfqWgHFlXpaW4WCkCobUFq8TobMZtvg/CE 6x/mhaccexdHlhFNrxxXHPP/mROC78kOsLAQyhf0Ti021rZfKE+bRuT6+5LvH+E+mTH+ 0PC8/HlWrvcN7RJG8l+c6zfv/kZ0VcW7LqnErrA7rYPT6rZw9mFpAa1URXLJauYfKBXU eDbAcS+YUQf0o19QuKxmRHfXBuic9QmNrbwgyLLgu8XF/qDu8rajYn91hndvASWb/W5K gmOcrdDxIvhZb9Bbk8Fi38KooSzmD4FTyYox+07LoxLB5nvKQaMJsr4k9mFq2pQJcFkE 1Guw== X-Gm-Message-State: AOJu0YzZVAgREQEbFOc753RXp6qWk4z+auHxBKaZX4QqUKalRwJh7M7f WmMUKniMpe4yjgHJc6XGc/CZIwViYxKqlyIvrA/1Gva3Tm+JaBSMjo7FG77ypxS24PjhFI7ehHk = X-Google-Smtp-Source: AGHT+IFHp6bZpFGTH68DGBb/NFZNIoIPDjgv9UFhrFp/s5uwBtC2RSEnQp1VQKeywlZ+2pazUvucLg== X-Received: by 2002:a0d:f744:0:b0:5ff:81fa:16e6 with SMTP id h65-20020a0df744000000b005ff81fa16e6mr833547ywf.38.1707523069920; Fri, 09 Feb 2024 15:57:49 -0800 (PST) Received: from vader (68-252-220-225.lightspeed.tukrga.sbcglobal.net. [68.252.220.225]) by smtp.gmail.com with ESMTPSA id t192-20020a8183c9000000b006042879cc1asm110200ywf.98.2024.02.09.15.57.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 15:57:49 -0800 (PST) From: Martin Marshall To: emacs-orgmode@gnu.org Subject: [PATCH] `org-ctags-create-tags` creates empty TAGS file [9.6.15 (release_9.6.15 @ /home/martin/Projects/emacs/lisp/org/)] Date: Fri, 09 Feb 2024 18:57:48 -0500 Message-ID: <87h6ihgphf.fsf@martinmarshall.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: none client-ip=2607:f8b0:4864:20::112d; envelope-from=law@martinmarshall.com; helo=mail-yw1-x112d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -9.31 X-Migadu-Queue-Id: D035D5BE6C X-Spam-Score: -9.31 X-Migadu-Scanner: mx11.migadu.com X-TUID: DTLgZdVLZopE --=-=-= Content-Type: text/plain Hi, the docstring of `org-ctags-create-tags` says it should "(Re)create tags file in the directory of the active buffer," creating tags from the internal links found in the org files. However, it always creates an empty TAGS file. The cause appears to be a pair of escaped quotes used with `shell-command` when it calls the "ctags" executable. * Re-creating the issue 1. First, as explained in the commentary of "org-ctags.el", make sure you have exuberant-ctags installed on your system. On a debian-based system, like so... --8<---------------cut here---------------start------------->8--- sudo apt install exuberant-ctags --8<---------------cut here---------------end--------------->8--- 2. Start Emacs from the command-line with "emacs -Q". 3. In the "*scratch*" buffer, paste the expression shown below. --8<---------------cut here---------------start------------->8--- (let* ((testdir (expand-file-name "test1234xyz" "~")) (orgfile (expand-file-name "test-file.org" testdir)) (tagsfile (expand-file-name "TAGS" testdir))) (unless (file-exists-p testdir) (make-directory testdir)) (find-file orgfile) (insert "<>") (save-buffer) (require 'org-ctags) (org-ctags-create-tags testdir) (find-file tagsfile)) --8<---------------cut here---------------end--------------->8--- 4. If you evaluate the above code. It creates the "~/test1234xyz" directory, an org file containing a link, and a new TAGS file. It also opens the new TAGS file. But as you can see, it's empty. * Cause The cause appears to be some escaped quotes around a shell command argument. The FILES argument passed to the "ctags" executable uses globbing. But since it's surrounded by double quotes, no globbing occurs, and "ctags" doesn't actually scan any files. If we change this: "--regex-orgmode=\"%s\" -f \"%s\" -e -R \"%s\"") To this: "--regex-orgmode=\"%s\" -f \"%s\" -e -R %s") It works as expected. I've attached a patch against the current Emacs master branch. I hope that's sufficient, given the minimal nature of the change. Emacs : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.16.0) of 2024-02-09 Package: Org mode version 9.6.15 (release_9.6.15 @ /home/martin/Projects/emacs/lisp/org/) --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-org-ctags-create-tags-shell-command.patch Content-Description: Fix for org-ctags-create-tags command >From a6719edafd928a5ce27036be5d5bec00eaafa8ec Mon Sep 17 00:00:00 2001 From: Martin Marshall Date: Fri, 9 Feb 2024 17:40:03 -0500 Subject: [PATCH] org-ctags.el: Fix use of "ctags" executable * lisp/org/org-ctags.el (org-ctags-create-tags): Allow file globbing in `shell-command' invocation of "ctags". TINYCHANGE --- lisp/org/org-ctags.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org/org-ctags.el b/lisp/org/org-ctags.el index 2417353ee5d..9e523e7dc67 100644 --- a/lisp/org/org-ctags.el +++ b/lisp/org/org-ctags.el @@ -486,7 +486,7 @@ org-ctags-create-tags (setq exitcode (shell-command (format (concat "%s --langdef=orgmode --langmap=orgmode:.org " - "--regex-orgmode=\"%s\" -f \"%s\" -e -R \"%s\"") + "--regex-orgmode=\"%s\" -f \"%s\" -e -R %s") org-ctags-path-to-ctags org-ctags-tag-regexp (expand-file-name (concat dir-name "/TAGS")) -- 2.39.2 --=-=-= Content-Type: text/plain -- Best regards, Martin Marshall --=-=-=--