* Toio little error information from widgets
@ 2007-02-06 23:53 Lennart Borgman (gmail)
2007-02-07 0:08 ` Daniel Brockman
0 siblings, 1 reply; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-06 23:53 UTC (permalink / raw)
To: Emacs Devel
The following code has an error. This error is however very hard to
detect. I do not get a traceback, it just behaves very strange.
Try the following:
emacs -Q
(eval the code below)
M-x customize-option RET temp-cust2 RET
Then click INS. It does not work as I expect. (To get it working
uncomment the line
;;(or (eq value 'fundamental-mode)
and the corresponding ")" in the code.
What could be done about this?
Here is the code:
(defun major-modep(value)
(let ((sym-name (symbol-name value)))
;; Do some reasonable test to find out if it is a major mode.
;; Load autoloaded mode functions.
;;
;; Fix-me: Maybe test for minor modes? How was that done?
(when (and (fboundp value)
(< 5 (length sym-name))
(string= "-mode" (substring sym-name (- (length
sym-name) 5)))
(if (and (listp (symbol-function value))
(eq 'autoload (car (symbol-function value))))
(progn
(message "loading ")
(load (cadr (symbol-function value)) t t))
t)
;;(or (eq value 'fundamental-mode)
(intern-soft (concat sym-name "-hook"))
(boundp (intern-soft (concat sym-name "-hook"))))
;;)
t)))
(define-widget 'major-mode-function2 'function
"A major mode lisp function."
:complete-function (lambda ()
(interactive)
(lisp-complete-symbol 'major-modep))
:prompt-match 'major-modep
:prompt-history 'widget-function-prompt-value-history
:match-alternatives '(major-modep)
:validate (lambda (widget)
(unless (major-modep (widget-value widget))
(widget-put widget :error (format "Invalid function: %S"
(widget-value widget)))
widget))
:value 'fundamental-mode
:tag "Major mode function")
(defcustom temp-cust2 nil
"doc"
:type '(alist :key-type major-mode-function2
:value-type (set
(list :tag "Highlighting on" (const hion)
boolean)
(list :tag "Highlighting" (const hili)
function)
(list :tag "Goto" (const goto) function)
(list :tag "Next" (const next) function)
(list :tag "Prev" (const next) function)
)))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Toio little error information from widgets
2007-02-06 23:53 Toio little error information from widgets Lennart Borgman (gmail)
@ 2007-02-07 0:08 ` Daniel Brockman
2007-02-07 0:17 ` Lennart Borgman (gmail)
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Brockman @ 2007-02-07 0:08 UTC (permalink / raw)
To: emacs-devel
"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
> ;;(or (eq value 'fundamental-mode)
> (intern-soft (concat sym-name "-hook"))
> (boundp (intern-soft (concat sym-name "-hook"))))
> ;;)
This part does not make sense:
(or (intern-soft (concat sym-name "-hook"))
(boundp (intern-soft (boncat sym-name "-hook"))))
In general, nothing that looks like this can make sense,
(or FOO (boundp FOO))
because `boundp' will only ever be called if FOO is nil.
--
Daniel Brockman <daniel@brockman.se>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Toio little error information from widgets
2007-02-07 0:08 ` Daniel Brockman
@ 2007-02-07 0:17 ` Lennart Borgman (gmail)
2007-02-07 23:47 ` Lennart Borgman (gmail)
0 siblings, 1 reply; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-07 0:17 UTC (permalink / raw)
To: Daniel Brockman; +Cc: emacs-devel
Daniel Brockman wrote:
> "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
>
>> ;;(or (eq value 'fundamental-mode)
>> (intern-soft (concat sym-name "-hook"))
>> (boundp (intern-soft (concat sym-name "-hook"))))
>> ;;)
>
> This part does not make sense:
>
> (or (intern-soft (concat sym-name "-hook"))
> (boundp (intern-soft (boncat sym-name "-hook"))))
>
> In general, nothing that looks like this can make sense,
>
> (or FOO (boundp FOO))
>
> because `boundp' will only ever be called if FOO is nil.
>
Thamnks. Sorry, I just added the "fundamental-mode" line to make it more
clear when I posted. I missed to put and "add" around the following two
lines.
It should be
;;(or (eq value 'fundamental-mode)
;; (and
(intern-soft (concat sym-name "-hook"))
(boundp (intern-soft (concat sym-name "-hook"))))
;;))
Both the "fundamental-line" and the "and" line must be uncommented to
get it working.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Toio little error information from widgets
2007-02-07 0:17 ` Lennart Borgman (gmail)
@ 2007-02-07 23:47 ` Lennart Borgman (gmail)
0 siblings, 0 replies; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2007-02-07 23:47 UTC (permalink / raw)
To: Lennart Borgman (gmail); +Cc: Daniel Brockman, emacs-devel
Lennart Borgman (gmail) wrote:
> Daniel Brockman wrote:
>> "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
>>
>>> ;;(or (eq value 'fundamental-mode)
>>> (intern-soft (concat sym-name "-hook"))
>>> (boundp (intern-soft (concat sym-name "-hook"))))
>>> ;;)
>>
>> This part does not make sense:
>>
>> (or (intern-soft (concat sym-name "-hook"))
>> (boundp (intern-soft (boncat sym-name "-hook"))))
>>
>> In general, nothing that looks like this can make sense,
>>
>> (or FOO (boundp FOO))
>>
>> because `boundp' will only ever be called if FOO is nil.
>>
>
> Thamnks. Sorry, I just added the "fundamental-mode" line to make it more
> clear when I posted. I missed to put and "add" around the following two
> lines.
>
> It should be
> ;;(or (eq value 'fundamental-mode)
> ;; (and
> (intern-soft (concat sym-name "-hook"))
> (boundp (intern-soft (concat sym-name "-hook"))))
> ;;))
>
> Both the "fundamental-line" and the "and" line must be uncommented to
> get it working.
I looked a little bit further. The error (which a bit surprisingly is
"End of file during parsing") happens in `widget-apply' which is called
from `widget-insert-button-action'.
`widget-apply' internally calls Fapply, which is `apply'.
The message buffer contains
Debug on Error enabled globally
End of file during parsing
Back to top level.
There is no problem just calling a function which gets an error during
apply, something like this
(defun temp-bad-div(x)
(interactive "nNumber: ")
(message "%s" (apply '/ 100 (list x))))
This gives the trace-back I expect if called with x=0.
`widget-apply' is very short and the crucial part looks like
GCPRO2 (newargs[0], newargs[2]);
result = Fapply (3, newargs);
UNGCPRO;
However i have not much idea about what GCPRO2 does so maybe someone who
knows that can look a bit further? Why does not the trace-back appear here?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-02-07 23:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-06 23:53 Toio little error information from widgets Lennart Borgman (gmail)
2007-02-07 0:08 ` Daniel Brockman
2007-02-07 0:17 ` Lennart Borgman (gmail)
2007-02-07 23:47 ` Lennart Borgman (gmail)
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.