>From ead257cbfc2c7e9196210b899f6d4e6496c0a42b Mon Sep 17 00:00:00 2001 From: Phil Sainty Date: Mon, 16 Oct 2017 23:38:42 +1300 Subject: [PATCH] Don't clobber docstrings of explicitly-defined mode hook variables * lisp/emacs-lisp/derived.el (define-derived-mode): * lisp/emacs-lisp/easy-mmode.el (define-minor-mode): When defining the mode hook variable, do not clobber pre-existing docstrings. --- lisp/emacs-lisp/derived.el | 8 +++++--- lisp/emacs-lisp/easy-mmode.el | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/emacs-lisp/derived.el b/lisp/emacs-lisp/derived.el index 3fa3818..e8910d1 100644 --- a/lisp/emacs-lisp/derived.el +++ b/lisp/emacs-lisp/derived.el @@ -203,11 +203,13 @@ define-derived-mode parent child docstring syntax abbrev)) `(progn - (defvar ,hook nil - ,(format "Hook run after entering %s mode. + (defvar ,hook nil) + (unless (get ',hook 'variable-documentation) + (put ',hook 'variable-documentation + ,(format "Hook run after entering %s mode. No problems result if this variable is not bound. `add-hook' automatically binds it. (This is true for all hook variables.)" - name)) + name))) (unless (boundp ',map) (put ',map 'definition-name ',child)) (with-no-warnings (defvar ,map (make-sparse-keymap))) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index bf087fc..220691c 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -309,11 +309,13 @@ define-minor-mode ;; up-to-here. :autoload-end - (defvar ,hook nil - ,(format "Hook run after entering or leaving `%s'. + (defvar ,hook nil) + (unless (get ',hook 'variable-documentation) + (put ',hook 'variable-documentation + ,(format "Hook run after entering or leaving `%s'. No problems result if this variable is not bound. `add-hook' automatically binds it. (This is true for all hook variables.)" - modefun)) + modefun))) ;; Define the minor-mode keymap. ,(unless (symbolp keymap) ;nil is also a symbol. -- 2.8.3