From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Eli Zaretskii <eliz@gnu.org>
Cc: monnier@IRO.UMontreal.CA, emacs-devel@gnu.org
Subject: Re: Byte-compilation of custom themes
Date: Fri, 11 May 2018 21:43:42 +0100 [thread overview]
Message-ID: <877eo9kjnl.fsf@tcd.ie> (raw)
In-Reply-To: <83a7t6nlmf.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 11 May 2018 20:32:56 +0300")
[-- Attachment #1: Type: text/plain, Size: 1206 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: "Basil L. Contovounesios" <contovob@tcd.ie>
>> Cc: <monnier@IRO.UMontreal.CA>, <emacs-devel@gnu.org>
>> Date: Fri, 11 May 2018 16:16:09 +0100
>>
>> > The original code carefully verified that the members in
>> > custom-theme--load-path are directories, whereas your proposal calls
>> > directory-files on each member unconditionally, which will barf if a
>> > file is not a directory.
>>
>> The function custom-theme--load-path already incorporates the
>> file-directory-p check, so it is technically redundant here.
>> Would you rather it be kept regardless?
>
> We should at least have a comment there that we are relying on
> custom-theme--load-path to do the test, and perhaps also an assertion.
Do you mean a cl-assertion, or an emulation thereof? E.g.:
(unless (file-directory-p dir)
(signal 'file-missing
(list "`custom-theme-load-path'" "No such directory" dir)))
(I'm unsure on the convention for file-missing errors.)
Either way, what is the benefit of barfing before directory-files does?
Wouldn't a docstring for custom-theme--load-path and a comment in
custom-available-themes suffice for the reader (they do for me)? E.g.:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: custom.diff --]
[-- Type: text/x-diff, Size: 843 bytes --]
diff --git a/lisp/custom.el b/lisp/custom.el
index b3311a1783..d21e398646 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -1292,6 +1292,7 @@ custom-available-themes
(let ((suffix "-theme\\.el\\'")
themes)
(dolist (dir (custom-theme--load-path))
+ ;; `custom-theme--load-path' promises DIR exists.
(dolist (file (directory-files dir nil suffix))
(let ((theme (intern (substring file 0 (string-match-p suffix file)))))
(and (custom-theme-name-valid-p theme)
@@ -1300,6 +1301,8 @@ custom-available-themes
(nreverse themes)))
(defun custom-theme--load-path ()
+ "Expand `custom-theme-load-path' into list of directories.
+Only existing directories are included in the path returned."
(let (lpath)
(dolist (f custom-theme-load-path)
(cond ((eq f 'custom-theme-directory)
[-- Attachment #3: Type: text/plain, Size: 1517 bytes --]
>> >> - (define-key map "\C-x\C-s" 'custom-theme-write)
>> >> - (define-key map "q" 'Custom-buffer-done)
>> >> - (define-key map "n" 'widget-forward)
>> >> - (define-key map "p" 'widget-backward)
>> >> + (define-key map "\C-x\C-s" #'custom-theme-write)
>> >> + (define-key map "q" #'Custom-buffer-done)
>> >> + (define-key map "n" #'widget-forward)
>> >> + (define-key map "p" #'widget-backward)
>> >
>> > Really? Are we going to switch to #'foo even in key bindings?
>>
>> Though I personally prefer to consistently #'-quote function symbols in
>> my own code, both for the extra byte-compiler check and narrower
>> in-buffer completion, I have no strong opinion here; I was simply making
>> the change in a sweeping fashion, in line with what I had perceived as a
>> welcome style. Out of curiosity, though, what makes key bindings
>> special w.r.t. quoting?
>
> Stefan gave one reason (with which I agree). From POV, it's another
> stab into my heart of a veteran reader of Emacs Lisp code. I recently
> find the code harder and harder to read due to all the new syntax and
> unfamiliar functions. You can ignore me on that, though.
No, it's a respectable point and I appreciate it. Besides, my original
intent was to change how themes are loaded, not how their libraries are
quoted; I simply got carried away, and I'm sure there's precedent on the
latter elsewhere. Let me know whether any heart stabs remain in the
last patchset and I'll gladly revert them.
Thanks,
--
Basil
next prev parent reply other threads:[~2018-05-11 20:43 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-20 21:01 Byte-compilation of custom themes Basil L. Contovounesios
2018-01-24 16:16 ` Stefan Monnier
2018-01-30 22:16 ` Basil L. Contovounesios
2018-01-31 2:26 ` Stefan Monnier
2018-02-01 0:45 ` Basil L. Contovounesios
2018-02-02 14:25 ` Stefan Monnier
2018-05-10 2:49 ` Basil L. Contovounesios
2018-05-10 2:54 ` Basil L. Contovounesios
2018-05-11 14:07 ` Eli Zaretskii
2018-05-11 14:02 ` Eli Zaretskii
2018-05-11 15:16 ` Basil L. Contovounesios
2018-05-11 16:03 ` Stefan Monnier
2018-05-11 20:03 ` Basil L. Contovounesios
2018-05-11 17:32 ` Eli Zaretskii
2018-05-11 20:43 ` Basil L. Contovounesios [this message]
2018-05-12 7:04 ` Eli Zaretskii
2018-06-01 20:48 ` Basil L. Contovounesios
2018-06-01 21:07 ` Basil L. Contovounesios
2018-06-02 11:24 ` Eli Zaretskii
2018-06-02 18:53 ` Basil L. Contovounesios
2018-06-02 19:32 ` Eli Zaretskii
2018-06-02 20:02 ` Basil L. Contovounesios
2018-06-03 3:52 ` Stefan Monnier
2018-06-03 11:21 ` Basil L. Contovounesios
2018-06-03 15:11 ` Eli Zaretskii
2018-06-03 16:08 ` Basil L. Contovounesios
2018-06-03 16:16 ` Eli Zaretskii
2018-06-03 17:48 ` Basil L. Contovounesios
2018-06-03 20:22 ` Stefan Monnier
2018-06-04 1:33 ` Basil L. Contovounesios
2018-07-03 7:57 ` Basil L. Contovounesios
2018-07-11 1:40 ` Stefan Monnier
2018-07-11 6:05 ` Basil L. Contovounesios
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877eo9kjnl.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.