Ihor Radchenko <yanta...@posteo.net> writes:

> Martin Marshall <l...@martinmarshall.com> writes:
>
>> 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.
>> ...
>> I've attached a patch against the current Emacs master branch.  I hope
>> that's sufficient, given the minimal nature of the change.
>
> Thanks!
> Applied, onto main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=981402a93

Doesn't this change mean that it will now break when the expanded path
has whitespace characters in it?

The shell expansion should work if the asterisk is outside of the
quotes.  I've attached an (untested) patch to explain what I mean.

-- 
Morgan Willcock
>From b5f52034b693175df2ec057cb5e9e4de55e70078 Mon Sep 17 00:00:00 2001
From: Morgan Willcock <morgan@ice9.digital>
Date: Sat, 10 Feb 2024 21:02:30 +0000
Subject: [PATCH] org-ctags.el: Quote directory name for "ctags" shell command

* lisp/org-ctags.el (org-ctags-create-tags): Expand the quoted form of
the directory name in the "ctags" shell command.  This allows the
directory name to contain whitespace characters.
---
 lisp/org-ctags.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-ctags.el b/lisp/org-ctags.el
index 693ccc87b..49c1d1228 100644
--- a/lisp/org-ctags.el
+++ b/lisp/org-ctags.el
@@ -484,11 +484,11 @@ defun 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"))
-                     (expand-file-name (concat dir-name "/*")))))
+                     (expand-file-name (concat dir-name "/")))))
       (cond
        ((eql 0 exitcode)
         (setq-local org-ctags-tag-list
-- 
2.41.0.windows.3

Reply via email to