all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Phil Sainty <psainty@orcon.net.nz>
Cc: 28863@debbugs.gnu.org
Subject: bug#28863: 26.0.90; [PATCH] Don't clobber docstrings of explicitly-defined mode hook variables
Date: Sat, 21 Oct 2017 19:03:08 -0400	[thread overview]
Message-ID: <874lqsdryr.fsf@users.sourceforge.net> (raw)
In-Reply-To: <0e9fedfc-ee21-3c9b-2455-17ae5f128d7f@orcon.net.nz> (Phil Sainty's message of "Tue, 17 Oct 2017 01:35:43 +1300")

severity 28863 minor
quit

Phil Sainty <psainty@orcon.net.nz> writes:

> 1. If the mode is defined first:
>
> (define-derived-mode foo-mode ...)
> (defcustom foo-mode-hook '(default value) "docstring")
>
> Then `foo-mode-hook' has already been defvar'd with a value of nil,
> and so the defcustom default value never gets set, so that sequence
> is no good.

Giving a default value to a hook variable is problematic, because if the
user has (add-hook 'foo-mode-hook 'some-other-fun) then they lose the
default-value if foo-mode.el wasn't loaded yet.  So the usual way to do
it is like this:

(defcustom foo-mode-hook nil "docstring")
(add-hook 'foo-mode-hook 'default-value)

> My suggestion is that `define-derived-mode' and `define-minor-mode'
> should only add the standard docstring to the mode hook variable
> conditional on that variable not *already* having a docstring.

Seems fine to me.

> Patch attached for consideration.

My only nitpick is that you seem to be adding tab-indented lines.





  reply	other threads:[~2017-10-21 23:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-16 12:35 bug#28863: 26.0.90; [PATCH] Don't clobber docstrings of explicitly-defined mode hook variables Phil Sainty
2017-10-21 23:03 ` Noam Postavsky [this message]
2017-10-22  2:51   ` Phil Sainty
2017-10-31 12:45     ` Noam Postavsky

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=874lqsdryr.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=28863@debbugs.gnu.org \
    --cc=psainty@orcon.net.nz \
    /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.