GNU bug report logs - #1102
23.0.60; add-hook should check that its function arg is a function.

Previous Next

Package: emacs;

Reported by: Phil Hagelberg <phil <at> hagelb.org>

Date: Mon, 6 Oct 2008 17:45:03 UTC

Severity: wishlist

Tags: wontfix

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Phil Hagelberg <phil <at> hagelb.org>
Subject: bug#1102: closed (Re: bug#1102: add-hook should check that its
 function arg is a function)
Date: Sat, 09 Jul 2011 18:47:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#1102: 23.0.60; add-hook should check that its function arg is a function.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 1102 <at> debbugs.gnu.org.

-- 
1102: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=1102
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Glenn Morris <rgm <at> gnu.org>
To: 1102-done <at> debbugs.gnu.org
Subject: Re: bug#1102: add-hook should check that its function arg is a
	function
Date: Sat, 09 Jul 2011 14:46:34 -0400
I don't see a need to keep open this particular report, which was marked
"wontfix" some time ago.

Phil Hagelberg wrote:

> Yeah, you're probably right; in retrospect I'm not sure why it's
> necessary. Feel free to close as a wontfix.

[Message part 3 (message/rfc822, inline)]
From: Phil Hagelberg <phil <at> hagelb.org>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.60; add-hook should check that its function arg is a function.
Date: Mon, 06 Oct 2008 09:59:57 -0700
add-hook may be called with a function argument that is not a function:

(add-hook 'emacs-lisp-mode-hook 22)

This is functionally a no-op since run-mode-hooks will ignore such
values, but it would probably be better to get an error when add-hook
is called.

Here's a patch. I'm not sure what the convention is for how these
types of error messages should read, so that could be changed.

diff --git a/lisp/subr.el b/lisp/subr.el
index d62b38b..49e9470 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1132,6 +1132,7 @@ HOOK is void, it is first set to nil.  If HOOK's value is a single
 function, it is changed to a list of functions."
   (or (boundp hook) (set hook nil))
   (or (default-boundp hook) (set-default hook nil))
+  (unless (functionp function) (error "`function' argument was not a function"))
   (if local (unless (local-variable-if-set-p hook)
 	      (set (make-local-variable hook) (list t)))
     ;; Detect the case where make-local-variable was used on a hook



In GNU Emacs 23.0.60.1 (i686-pc-linux-gnu, GTK+ Version 2.12.9)
 of 2008-09-29 on pdp10
Windowing system distributor `The X.Org Foundation', version 11.0.10400090
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Group

Minor modes in effect:
  shell-dirtrack-mode: t
  jabber-activity-mode: t
  gnus-topic-mode: t
  gnus-undo-mode: t
  show-paren-mode: t
  recentf-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
o k SPC ' g n u s - a r t i c l e - m o d e - h o o 
k C-S-h v <return> q SPC ' l o n g l i n e - <backspace> 
s - m o d e ) C-S-x C-S-s C-S-x C-S-e C-S-x k <return> 
C-S-x C-S-o SPC SPC SPC SPC M-x l o n g l i n e s - 
- <backspace> m o d e <return> M-x M-p <return> M-< 
C-S-x o C-S-p C-S-x o C-S-p <return> C-S-n <return> 
C-S-x o C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n 
C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n 
C-S-n C-S-n C-S-n C-S-n C-S-n C-S-v C-S-v C-S-v SPC 
SPC SPC SPC SPC C-S-x C-S-o C-S-n <return> C-S-n <return> 
C-S-n <return> C-S-n <return> C-S-n <return> C-S-n 
<return> C-S-n <return> C-S-n <return> C-S-n <return> 
C-S-n <return> C-S-n <return> C-S-n C-S-n <return> 
C-S-n <return> C-S-n <return> C-S-n <return> q g p 
<return> q C-S-n <return> k k k k k k q p n <return> 
d q g p <return> q p p <return> M-> C-S-p C-S-p C-S-p 
<return> C-S-n <down-mouse-1> <mouse-1> <help-echo> 
<down-mouse-1> <mouse-1> SPC C-S-x o C-S-x o M-u C-S-p 
<return> q g <down-mouse-1> <mouse-1> <down-mouse-1> 
<mouse-1> g p p p p <return> M-> p C-S-x o M-> M-< 
C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n 
C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n 
C-S-n C-S-n C-S-n C-S-n C-S-n C-S-n t t C-S-p C-S-p 
C-S-p <return> <help-echo> <down-mouse-1> <mouse-movement> 
<help-echo> <mouse-movement> <mouse-movement> <help-echo> 
<mouse-movement> <help-echo> <mouse-movement> <mouse-movement> 
<help-echo> <mouse-movement> <help-echo> <drag-mouse-1> 
<help-echo> <help-echo> <down-mouse-1> <mouse-1> C-S-x 
o C-S-x o ! C-S-p C-S-p <return> M-u <help-echo> q 
g M-x r e p o r t - e m a c s - b u g <return>

Recent messages:
Generating summary...done
Mark set [3 times]
No more articles [2 times]
Reading active file via nnnil...done
Reading active file via nnml...
nnml: Reading incoming mail from file...
nnml: Reading incoming mail (no new mail)...done
Reading active file via nnml...done
Reading active file from archive via nnfolder...done
Checking new news...done



This bug report was last modified 14 years and 13 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.