GNU bug report logs -
#65468
29.1; describe-theme fails to describe some themes not loaded
Previous Next
Reported by: Thierry Volpiatto <thievol <at> posteo.net>
Date: Wed, 23 Aug 2023 08:55:01 UTC
Severity: normal
Tags: patch
Found in version 29.1
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #20 received at 65468 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Thierry Volpiatto <thievol <at> 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
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 1 year and 351 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.