From: Thierry Volpiatto <thievol@posteo.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 65468@debbugs.gnu.org
Subject: bug#65468: 29.1; describe-theme fails to describe some themes not loaded
Date: Wed, 23 Aug 2023 13:12:28 +0000 [thread overview]
Message-ID: <87a5uhq4qp.fsf@posteo.net> (raw)
In-Reply-To: <83cyzerne5.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 2654 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Thierry Volpiatto <thievol@posteo.net>
>> Date: Wed, 23 Aug 2023 08:44:16 +0000
>>
>>
>> This because `describe-theme-1` is not looping in buffer to find
>> `deftheme` definition.
>
> We never did better, did we? IOW, this issue exists for a long time,
> right?
>
> If so, I think this should go to master, not to the emacs-29 branch.
I will not push anything, just proposing patch if any interest to fix
this issue, here a new patch that provide a separate function for this
part of code:
diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el
index 5d3f2585976..c6c9d9c892b 100644
--- a/lisp/cus-theme.el
+++ b/lisp/cus-theme.el
@@ -490,6 +490,29 @@ It includes all faces in list FACES."
(with-current-buffer standard-output
(describe-theme-1 theme))))
+(defun describe-theme-from-file (&optional file short)
+ "Describe theme from its file FILE without loading it.
+
+If FILE is nil try to find the file from the theme name in
+`custom-theme-load-path'.
+If SHORT is non nil show only the first line of documentation."
+ (let ((file (or file
+ (locate-file (concat (symbol-name theme) "-theme.el")
+ (custom-theme--load-path)
+ '("" "c")))))
+ (with-temp-buffer
+ (insert-file-contents file)
+ (catch 'found
+ (let (sexp)
+ (while (setq sexp (let ((read-circle nil))
+ (condition-case nil
+ (read (current-buffer))
+ (end-of-file nil))))
+ (when (eq (car-safe sexp) 'deftheme)
+ (throw 'found (if short
+ (car (split-string (nth 2 sexp) "\n"))
+ (nth 2 sexp))))))))))
+
(defun describe-theme-1 (theme)
(prin1 theme)
(princ " is a custom theme")
@@ -510,16 +533,9 @@ It includes all faces in list FACES."
(princ "It is loaded but disabled."))
(setq doc (get theme 'theme-documentation)))
(princ "It is not loaded.")
- ;; Attempt to grab the theme documentation
+ ;; Attempt to grab the theme documentation from file.
(when fn
- (with-temp-buffer
- (insert-file-contents fn)
- (let ((sexp (let ((read-circle nil))
- (condition-case nil
- (read (current-buffer))
- (end-of-file nil)))))
- (and (eq (car-safe sexp) 'deftheme)
- (setq doc (nth 2 sexp)))))))
+ (setq doc (describe-theme-from-file fn))))
(princ "\n\nDocumentation:\n")
(princ (if (stringp doc)
(substitute-command-keys doc)
--
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 686 bytes --]
next prev parent reply other threads:[~2023-08-23 13:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 8:44 bug#65468: 29.1; describe-theme fails to describe some themes not loaded Thierry Volpiatto
2023-08-23 9:53 ` Mauro Aranda
2023-08-23 11:01 ` Thierry Volpiatto
2023-08-23 11:57 ` Eli Zaretskii
2023-08-24 10:16 ` Mauro Aranda
2023-08-25 3:48 ` Protesilaos Stavrou
2023-08-23 11:47 ` Eli Zaretskii
2023-08-23 13:12 ` Thierry Volpiatto [this message]
2023-08-26 7:57 ` Eli Zaretskii
2023-08-26 15:31 ` Thierry Volpiatto
2023-09-09 11:33 ` Mauro Aranda
2023-09-09 11:47 ` Eli Zaretskii
2023-09-09 11:51 ` Stefan Kangas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a5uhq4qp.fsf@posteo.net \
--to=thievol@posteo.net \
--cc=65468@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).