* advice.el and special forms
@ 2005-07-14 19:43 Stuart D. Herring
2005-07-15 13:00 ` Lennart Staflin
0 siblings, 1 reply; 3+ messages in thread
From: Stuart D. Herring @ 2005-07-14 19:43 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]
There's a list of known special forms in advice.el, along with a function
to check membership in the list and a comment lamenting being unable to
determine directly if a subr is a special form. Presumably this predates
subr-arity: is there some reason not to wipe ad-special-forms and
ad-special-form-p and just use
(and (subrp def) (eq (cdr (subr-arity def)) 'unevalled))
? It's long enough (what with the safety check) that it would do well as
a standard function behaving like subrp (presumably in subr.el).
(defun special-form-p (object)
"Return t if OBJECT is a special form."
(and (subrp object) (eq (cdr (subr-arity object)) 'unevalled)))
If this sounds reasonable, I've attached a patch (which my mailer insists
should be application/octet-stream; sorry) that creates that function and
uses it (all two times that advice.el does this). If this counts as a
papers-needing change, I'm already trying to finish that process.
Davis Herring
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
[-- Attachment #2: sfp.patch --]
[-- Type: application/octet-stream, Size: 3044 bytes --]
diff -Nacr cvs/subr.el new/subr.el
*** cvs/subr.el 2005-07-14 13:25:56.000000000 -0600
--- new/subr.el 2005-07-14 13:28:41.000000000 -0600
***************
*** 2390,2395 ****
--- 2390,2399 ----
(subrp object) (byte-code-function-p object)
(eq (car-safe object) 'lambda)))
+ (defun special-form-p (object)
+ "Return t if OBJECT is a special form."
+ (and (subrp object) (eq (cdr (subr-arity object)) 'unevalled)))
+
(defun assq-delete-all (key alist)
"Delete from ALIST all elements whose car is `eq' to KEY.
Return the modified alist.
diff -Nacr cvs/advice.el new/advice.el
*** cvs/advice.el 2005-07-14 13:21:29.000000000 -0600
--- new/advice.el 2005-07-14 13:28:51.000000000 -0600
***************
*** 2464,2487 ****
"Take a macro function DEFINITION and make a lambda out of it."
`(cdr ,definition))
- ;; There is no way to determine whether some subr is a special form or not,
- ;; hence we need this list (which is probably out of date):
- (defvar ad-special-forms
- (let ((tem '(and catch cond condition-case defconst defmacro
- defun defvar function if interactive let let*
- or prog1 prog2 progn quote save-current-buffer
- save-excursion save-restriction save-window-excursion
- setq setq-default unwind-protect while
- with-output-to-temp-buffer)))
- ;; track-mouse could be void in some configurations.
- (if (fboundp 'track-mouse)
- (push 'track-mouse tem))
- (mapcar 'symbol-function tem)))
-
- (defmacro ad-special-form-p (definition)
- ;;"non-nil if DEFINITION is a special form."
- (list 'memq definition 'ad-special-forms))
-
(defmacro ad-interactive-p (definition)
;;"non-nil if DEFINITION can be called interactively."
(list 'commandp definition))
--- 2464,2469 ----
***************
*** 2644,2650 ****
(if (ad-macro-p definition)
'macro
(if (ad-subr-p definition)
! (if (ad-special-form-p definition)
'special-form
'subr)
(if (or (ad-lambda-p definition)
--- 2626,2632 ----
(if (ad-macro-p definition)
'macro
(if (ad-subr-p definition)
! (if (special-form-p definition)
'special-form
'subr)
(if (or (ad-lambda-p definition)
***************
*** 3062,3068 ****
(origname (ad-get-advice-info-field function 'origname))
(orig-interactive-p (ad-interactive-p origdef))
(orig-subr-p (ad-subr-p origdef))
! (orig-special-form-p (ad-special-form-p origdef))
(orig-macro-p (ad-macro-p origdef))
;; Construct the individual pieces that we need for assembly:
(orig-arglist (ad-arglist origdef function))
--- 3044,3050 ----
(origname (ad-get-advice-info-field function 'origname))
(orig-interactive-p (ad-interactive-p origdef))
(orig-subr-p (ad-subr-p origdef))
! (orig-special-form-p (special-form-p origdef))
(orig-macro-p (ad-macro-p origdef))
;; Construct the individual pieces that we need for assembly:
(orig-arglist (ad-arglist origdef function))
[-- Attachment #3: ChangeLog --]
[-- Type: application/octet-stream, Size: 252 bytes --]
2005-07-14 Davis Herring <herring@lanl.gov>
* subr.el (special-form-p): New function.
* advice.el (ad-special-forms): Remove variable.
(ad-special-form-p): Remove function.
(ad-definition-type, ad-make-advised-definition): Use
special-form-p.
[-- Attachment #4: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: advice.el and special forms
2005-07-14 19:43 advice.el and special forms Stuart D. Herring
@ 2005-07-15 13:00 ` Lennart Staflin
2005-07-15 17:36 ` Luc Teirlinck
0 siblings, 1 reply; 3+ messages in thread
From: Lennart Staflin @ 2005-07-15 13:00 UTC (permalink / raw)
Cc: emacs-devel
On 14 jul 2005, at 21:43, Stuart D. Herring wrote:
>
> (defun special-form-p (object)
> "Return t if OBJECT is a special form."
> (and (subrp object) (eq (cdr (subr-arity object)) 'unevalled)))
>
I know that Emacs Lisp isn't Common Lisp, but isn't special-operator-p
a better name?
//Lennart Staflin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: advice.el and special forms
2005-07-15 13:00 ` Lennart Staflin
@ 2005-07-15 17:36 ` Luc Teirlinck
0 siblings, 0 replies; 3+ messages in thread
From: Luc Teirlinck @ 2005-07-15 17:36 UTC (permalink / raw)
Cc: emacs-devel
Lennart Staflin wrote:
On 14 jul 2005, at 21:43, Stuart D. Herring wrote:
>
> (defun special-form-p (object)
> "Return t if OBJECT is a special form."
> (and (subrp object) (eq (cdr (subr-arity object)) 'unevalled)))
>
I know that Emacs Lisp isn't Common Lisp, but isn't special-operator-p
a better name?
They are rather consistently called "special forms" in the Elisp docs.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-07-15 17:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-14 19:43 advice.el and special forms Stuart D. Herring
2005-07-15 13:00 ` Lennart Staflin
2005-07-15 17:36 ` Luc Teirlinck
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.