[COMMIT] Sync #'truncate-string-to-width with GNU, add tests for it.
12 years, 7 months
Aidan Kehoe
APPROVE COMMIT
NOTE: This patch has been committed.
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1336841465 -3600
# Node ID 00fd55d635fb2db4fb3b4647b1380769536f921c
# Parent 0df4d95bd98a41c9a7826a307427e6f6dbcb9842
Sync #'truncate-string-to-width with GNU, add tests for it.
lisp/ChangeLog addition:
2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
* subr.el:
* subr.el (truncate-string-to-width):
Sync with GNU's version, use its test suite in mule-tests.el.
tests/ChangeLog addition:
2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/mule-tests.el:
Test #'truncate-string-to-width, thank you Colin Walters.
diff -r 0df4d95bd98a -r 00fd55d635fb lisp/ChangeLog
--- a/lisp/ChangeLog Sat May 12 15:03:24 2012 +0100
+++ b/lisp/ChangeLog Sat May 12 17:51:05 2012 +0100
@@ -1,3 +1,9 @@
+2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * subr.el:
+ * subr.el (truncate-string-to-width):
+ Sync with GNU's version, use its test suite in mule-tests.el.
+
2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
* byte-optimize.el (byte-compile-unfold-lambda):
diff -r 0df4d95bd98a -r 00fd55d635fb lisp/subr.el
--- a/lisp/subr.el Sat May 12 15:03:24 2012 +0100
+++ b/lisp/subr.el Sat May 12 17:51:05 2012 +0100
@@ -1030,76 +1030,60 @@
(replace (the string string) obj :start1 idx)
(prog1 string (aset string idx obj))))
-;; From FSF 21.1; ELLIPSES is XEmacs addition.
+;; XEmacs; this is in mule-util in GNU. See tests/automated/mule-tests.el for
+;; the tests that Colin Walters includes in that file.
+(defun truncate-string-to-width (str end-column
+ &optional start-column padding ellipsis)
+ "Truncate string STR to end at column END-COLUMN.
+The optional 3rd arg START-COLUMN, if non-nil, specifies the starting
+column; that means to return the characters occupying columns
+START-COLUMN ... END-COLUMN of STR. Both END-COLUMN and START-COLUMN
+are specified in terms of character display width in the current
+buffer; see also `char-width'.
-(defun truncate-string-to-width (str end-column &optional start-column padding
- ellipses)
- "Truncate string STR to end at column END-COLUMN.
-The optional 3rd arg START-COLUMN, if non-nil, specifies
-the starting column; that means to return the characters occupying
-columns START-COLUMN ... END-COLUMN of STR.
-
-The optional 4th arg PADDING, if non-nil, specifies a padding character
-to add at the end of the result if STR doesn't reach column END-COLUMN,
-or if END-COLUMN comes in the middle of a character in STR.
-PADDING is also added at the beginning of the result
-if column START-COLUMN appears in the middle of a character in STR.
+The optional 4th arg PADDING, if non-nil, specifies a padding
+character (which should have a display width of 1) to add at the end
+of the result if STR doesn't reach column END-COLUMN, or if END-COLUMN
+comes in the middle of a character in STR. PADDING is also added at
+the beginning of the result if column START-COLUMN appears in the
+middle of a character in STR.
If PADDING is nil, no padding is added in these cases, so
the resulting string may be narrower than END-COLUMN.
-BUG: Currently assumes that the padding character is of width one. You
-will get weird results if not.
-
-If ELLIPSES is non-nil, add ellipses (specified by ELLIPSES if a string,
-else `...') if STR extends past END-COLUMN. The ellipses will be added in
-such a way that the total string occupies no more than END-COLUMN columns
--- i.e. if the string goes past END-COLUMN, it will be truncated somewhere
-short of END-COLUMN so that, with the ellipses added (and padding, if the
-proper place to truncate the string would be in the middle of a character),
-the string occupies exactly END-COLUMN columns."
+If ELLIPSIS is non-nil, it should be a string which will replace the
+end of STR (including any padding) if it extends beyond END-COLUMN,
+unless the display width of STR is equal to or less than the display
+width of ELLIPSIS. If it is non-nil and not a string, then ELLIPSIS
+defaults to \"...\"."
(or start-column
(setq start-column 0))
- (let ((len (length str))
+ (when (and ellipsis (not (stringp ellipsis)))
+ (setq ellipsis "..."))
+ (let ((str-len (length str))
+ (str-width (string-width str))
+ (ellipsis-len (if ellipsis (length ellipsis) 0))
+ (ellipsis-width (if ellipsis (string-width ellipsis) 0))
(idx 0)
(column 0)
(head-padding "") (tail-padding "")
ch last-column last-idx from-idx)
-
- ;; find the index of START-COLUMN; bail out if end of string reached.
(condition-case nil
(while (< column start-column)
(setq ch (aref str idx)
column (+ column (char-width ch))
idx (1+ idx)))
- (args-out-of-range (setq idx len)))
+ (args-out-of-range (setq idx str-len)))
(if (< column start-column)
- ;; if string ends before START-COLUMN, return either a blank string
- ;; or a string entirely padded.
- (if padding (make-string (- end-column start-column) padding) "")
- (if (and padding (> column start-column))
- (setq head-padding (make-string (- column start-column) padding)))
+ (if padding (make-string end-column padding) "")
+ (when (and padding (> column start-column))
+ (setq head-padding (make-string (- column start-column) padding)))
(setq from-idx idx)
- ;; If END-COLUMN is before START-COLUMN, then bail out.
- (if (< end-column column)
- (setq idx from-idx ellipses "")
-
- ;; handle ELLIPSES
- (cond ((null ellipses) (setq ellipses ""))
- ((if (<= (string-width str) end-column)
- ;; string fits, no ellipses
- (setq ellipses "")))
- (t
- ;; else, insert default value and ...
- (or (stringp ellipses) (setq ellipses "..."))
- ;; ... take away the width of the ellipses from the
- ;; destination. do all computations with new, shorter
- ;; width. the padding computed will get us exactly up to
- ;; the shorted width, which is right -- it just gets added
- ;; to the right of the ellipses.
- (setq end-column (- end-column (string-width ellipses)))))
-
- ;; find the index of END-COLUMN; bail out if end of string reached.
+ (when (>= end-column column)
+ (if (and (< end-column str-width)
+ (> str-width ellipsis-width))
+ (setq end-column (- end-column ellipsis-width))
+ (setq ellipsis ""))
(condition-case nil
(while (< column end-column)
(setq last-column column
@@ -1107,20 +1091,14 @@
ch (aref str idx)
column (+ column (char-width ch))
idx (1+ idx)))
- (args-out-of-range (setq idx len)))
- ;; if we went too far (stopped in middle of character), back up.
- (if (> column end-column)
- (setq column last-column idx last-idx))
- ;; compute remaining padding
- (if (and padding (< column end-column))
- (setq tail-padding (make-string (- end-column column) padding))))
- ;; get substring ...
- (setq str (substring str from-idx idx))
- ;; and construct result
- (if padding
- (concat head-padding str tail-padding ellipses)
- (concat str ellipses)))))
-
+ (args-out-of-range (setq idx str-len)))
+ (when (> column end-column)
+ (setq column last-column
+ idx last-idx))
+ (when (and padding (< column end-column))
+ (setq tail-padding (make-string (- end-column column) padding))))
+ (concat head-padding (substring str from-idx idx)
+ tail-padding ellipsis))))
;; alist/plist functions
(defun plist-to-alist (plist)
diff -r 0df4d95bd98a -r 00fd55d635fb tests/ChangeLog
--- a/tests/ChangeLog Sat May 12 15:03:24 2012 +0100
+++ b/tests/ChangeLog Sat May 12 17:51:05 2012 +0100
@@ -1,3 +1,8 @@
+2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * automated/mule-tests.el:
+ Test #'truncate-string-to-width, thank you Colin Walters.
+
2012-05-06 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/lisp-tests.el:
diff -r 0df4d95bd98a -r 00fd55d635fb tests/automated/mule-tests.el
--- a/tests/automated/mule-tests.el Sat May 12 15:03:24 2012 +0100
+++ b/tests/automated/mule-tests.el Sat May 12 17:51:05 2012 +0100
@@ -808,7 +808,81 @@
(Assert (let (default-process-coding-system)
(shell-command "cat </dev/null >/dev/null")
t))))
-
+ ;;; Test suite for truncate-string-to-width, from Colin Walters' tests in
+ ;;; mult-util.el in GNU.
+ (macrolet
+ ((test-truncate-string-to-width (&rest tests)
+ (let ((decode-any-string
+ ;; We can't store the East Asian characters directly in this
+ ;; file, since it needs to be read (but not executed) by
+ ;; non-Mule. Store them as UTF-8, decode them at
+ ;; macro-expansion time.
+ #'(lambda (object)
+ (if (stringp object)
+ (decode-coding-string object 'utf-8)
+ object))))
+ (cons
+ 'progn
+ (mapcar
+ (function*
+ (lambda ((arguments . result))
+ `(Assert (equal (truncate-string-to-width
+ ,@(mapcar decode-any-string arguments))
+ ,(funcall decode-any-string result)))))
+ tests)))))
+ (test-truncate-string-to-width
+ (("" 0) . "")
+ (("x" 1) . "x")
+ (("xy" 1) . "x")
+ (("xy" 2 1) . "y")
+ (("xy" 0) . "")
+ (("xy" 3) . "xy")
+ (("\344\270\255" 0) . "")
+ (("\344\270\255" 1) . "")
+ (("\344\270\255" 2) . "\344\270\255")
+ (("\344\270\255" 1 nil ? ) . " ")
+ (("\344\270\255\346\226\207" 3 1 ? ) . " ")
+ (("x\344\270\255x" 2) . "x")
+ (("x\344\270\255x" 3) . "x\344\270\255")
+ (("x\344\270\255x" 3) . "x\344\270\255")
+ (("x\344\270\255x" 4 1) . "\344\270\255x")
+ (("kor\355\225\234e\352\270\200an" 8 1 ? ) .
+ "or\355\225\234e\352\270\200")
+ (("kor\355\225\234e\352\270\200an" 7 2 ? ) . "r\355\225\234e ")
+ (("" 0 nil nil "...") . "")
+ (("x" 3 nil nil "...") . "x")
+ (("\344\270\255" 3 nil nil "...") . "\344\270\255")
+ (("foo" 3 nil nil "...") . "foo")
+ (("foo" 2 nil nil "...") . "fo") ;; (old) XEmacs failure?
+ (("foobar" 6 0 nil "...") . "foobar")
+ (("foobarbaz" 6 nil nil "...") . "foo...")
+ (("foobarbaz" 7 2 nil "...") . "ob...")
+ (("foobarbaz" 9 3 nil "...") . "barbaz")
+ (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 15
+ 1 ? t) . " h\343\202\223e\343\201\253l\343\201\241l\343\201\257o")
+ (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 14
+ 1 ? t) . " h\343\202\223e\343\201\253l\343\201\241...")
+ (("x" 3 nil nil "\347\262\265\350\252\236") . "x")
+ (("\344\270\255" 2 nil nil "\347\262\265\350\252\236") . "\344\270\255")
+ ;; XEmacs used to error
+ (("\344\270\255" 1 nil ?x "\347\262\265\350\252\236") . "x")
+ (("\344\270\255\346\226\207" 3 nil ? "\347\262\265\350\252\236") .
+ ;; XEmacs used to error
+ "\344\270\255 ")
+ (("foobarbaz" 4 nil nil "\347\262\265\350\252\236") .
+ "\347\262\265\350\252\236")
+ (("foobarbaz" 5 nil nil "\347\262\265\350\252\236") .
+ "f\347\262\265\350\252\236")
+ (("foobarbaz" 6 nil nil "\347\262\265\350\252\236") .
+ "fo\347\262\265\350\252\236")
+ (("foobarbaz" 8 3 nil "\347\262\265\350\252\236") .
+ "b\347\262\265\350\252\236")
+ (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 14
+ 4 ?x "\346\227\245\346\234\254\350\252\236") .
+ "xe\343\201\253\346\227\245\346\234\254\350\252\236")
+ (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 13
+ 4 ?x "\346\227\245\346\234\254\350\252\236") .
+ "xex\346\227\245\346\234\254\350\252\236")))
) ; end of tests that require MULE built in.
;;; end of mule-tests.el
--
‘Iodine deficiency was endemic in parts of the UK until, through what has been
described as “an unplanned and accidental public health triumph”, iodine was
added to cattle feed to improve milk production in the 1930s.’
(EN Pearce, Lancet, June 2011)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
commit/XEmacs: 2 new changesets
12 years, 7 months
Bitbucket
2 new commits in XEmacs:
https://bitbucket.org/xemacs/xemacs/changeset/00fd55d635fb/
changeset: 00fd55d635fb
user: kehoea
date: 2012-05-12 18:51:05
summary: Sync #'truncate-string-to-width with GNU, add tests for it.
lisp/ChangeLog addition:
2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
* subr.el:
* subr.el (truncate-string-to-width):
Sync with GNU's version, use its test suite in mule-tests.el.
tests/ChangeLog addition:
2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/mule-tests.el:
Test #'truncate-string-to-width, thank you Colin Walters.
affected #: 4 files
diff -r 0df4d95bd98a41c9a7826a307427e6f6dbcb9842 -r 00fd55d635fb2db4fb3b4647b1380769536f921c lisp/ChangeLog
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * subr.el:
+ * subr.el (truncate-string-to-width):
+ Sync with GNU's version, use its test suite in mule-tests.el.
+
2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
* byte-optimize.el (byte-compile-unfold-lambda):
diff -r 0df4d95bd98a41c9a7826a307427e6f6dbcb9842 -r 00fd55d635fb2db4fb3b4647b1380769536f921c lisp/subr.el
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1030,76 +1030,60 @@
(replace (the string string) obj :start1 idx)
(prog1 string (aset string idx obj))))
-;; From FSF 21.1; ELLIPSES is XEmacs addition.
+;; XEmacs; this is in mule-util in GNU. See tests/automated/mule-tests.el for
+;; the tests that Colin Walters includes in that file.
+(defun truncate-string-to-width (str end-column
+ &optional start-column padding ellipsis)
+ "Truncate string STR to end at column END-COLUMN.
+The optional 3rd arg START-COLUMN, if non-nil, specifies the starting
+column; that means to return the characters occupying columns
+START-COLUMN ... END-COLUMN of STR. Both END-COLUMN and START-COLUMN
+are specified in terms of character display width in the current
+buffer; see also `char-width'.
-(defun truncate-string-to-width (str end-column &optional start-column padding
- ellipses)
- "Truncate string STR to end at column END-COLUMN.
-The optional 3rd arg START-COLUMN, if non-nil, specifies
-the starting column; that means to return the characters occupying
-columns START-COLUMN ... END-COLUMN of STR.
-
-The optional 4th arg PADDING, if non-nil, specifies a padding character
-to add at the end of the result if STR doesn't reach column END-COLUMN,
-or if END-COLUMN comes in the middle of a character in STR.
-PADDING is also added at the beginning of the result
-if column START-COLUMN appears in the middle of a character in STR.
+The optional 4th arg PADDING, if non-nil, specifies a padding
+character (which should have a display width of 1) to add at the end
+of the result if STR doesn't reach column END-COLUMN, or if END-COLUMN
+comes in the middle of a character in STR. PADDING is also added at
+the beginning of the result if column START-COLUMN appears in the
+middle of a character in STR.
If PADDING is nil, no padding is added in these cases, so
the resulting string may be narrower than END-COLUMN.
-BUG: Currently assumes that the padding character is of width one. You
-will get weird results if not.
-
-If ELLIPSES is non-nil, add ellipses (specified by ELLIPSES if a string,
-else `...') if STR extends past END-COLUMN. The ellipses will be added in
-such a way that the total string occupies no more than END-COLUMN columns
--- i.e. if the string goes past END-COLUMN, it will be truncated somewhere
-short of END-COLUMN so that, with the ellipses added (and padding, if the
-proper place to truncate the string would be in the middle of a character),
-the string occupies exactly END-COLUMN columns."
+If ELLIPSIS is non-nil, it should be a string which will replace the
+end of STR (including any padding) if it extends beyond END-COLUMN,
+unless the display width of STR is equal to or less than the display
+width of ELLIPSIS. If it is non-nil and not a string, then ELLIPSIS
+defaults to \"...\"."
(or start-column
(setq start-column 0))
- (let ((len (length str))
+ (when (and ellipsis (not (stringp ellipsis)))
+ (setq ellipsis "..."))
+ (let ((str-len (length str))
+ (str-width (string-width str))
+ (ellipsis-len (if ellipsis (length ellipsis) 0))
+ (ellipsis-width (if ellipsis (string-width ellipsis) 0))
(idx 0)
(column 0)
(head-padding "") (tail-padding "")
ch last-column last-idx from-idx)
-
- ;; find the index of START-COLUMN; bail out if end of string reached.
(condition-case nil
(while (< column start-column)
(setq ch (aref str idx)
column (+ column (char-width ch))
idx (1+ idx)))
- (args-out-of-range (setq idx len)))
+ (args-out-of-range (setq idx str-len)))
(if (< column start-column)
- ;; if string ends before START-COLUMN, return either a blank string
- ;; or a string entirely padded.
- (if padding (make-string (- end-column start-column) padding) "")
- (if (and padding (> column start-column))
- (setq head-padding (make-string (- column start-column) padding)))
+ (if padding (make-string end-column padding) "")
+ (when (and padding (> column start-column))
+ (setq head-padding (make-string (- column start-column) padding)))
(setq from-idx idx)
- ;; If END-COLUMN is before START-COLUMN, then bail out.
- (if (< end-column column)
- (setq idx from-idx ellipses "")
-
- ;; handle ELLIPSES
- (cond ((null ellipses) (setq ellipses ""))
- ((if (<= (string-width str) end-column)
- ;; string fits, no ellipses
- (setq ellipses "")))
- (t
- ;; else, insert default value and ...
- (or (stringp ellipses) (setq ellipses "..."))
- ;; ... take away the width of the ellipses from the
- ;; destination. do all computations with new, shorter
- ;; width. the padding computed will get us exactly up to
- ;; the shorted width, which is right -- it just gets added
- ;; to the right of the ellipses.
- (setq end-column (- end-column (string-width ellipses)))))
-
- ;; find the index of END-COLUMN; bail out if end of string reached.
+ (when (>= end-column column)
+ (if (and (< end-column str-width)
+ (> str-width ellipsis-width))
+ (setq end-column (- end-column ellipsis-width))
+ (setq ellipsis ""))
(condition-case nil
(while (< column end-column)
(setq last-column column
@@ -1107,20 +1091,14 @@
ch (aref str idx)
column (+ column (char-width ch))
idx (1+ idx)))
- (args-out-of-range (setq idx len)))
- ;; if we went too far (stopped in middle of character), back up.
- (if (> column end-column)
- (setq column last-column idx last-idx))
- ;; compute remaining padding
- (if (and padding (< column end-column))
- (setq tail-padding (make-string (- end-column column) padding))))
- ;; get substring ...
- (setq str (substring str from-idx idx))
- ;; and construct result
- (if padding
- (concat head-padding str tail-padding ellipses)
- (concat str ellipses)))))
-
+ (args-out-of-range (setq idx str-len)))
+ (when (> column end-column)
+ (setq column last-column
+ idx last-idx))
+ (when (and padding (< column end-column))
+ (setq tail-padding (make-string (- end-column column) padding))))
+ (concat head-padding (substring str from-idx idx)
+ tail-padding ellipsis))))
;; alist/plist functions
(defun plist-to-alist (plist)
diff -r 0df4d95bd98a41c9a7826a307427e6f6dbcb9842 -r 00fd55d635fb2db4fb3b4647b1380769536f921c tests/ChangeLog
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * automated/mule-tests.el:
+ Test #'truncate-string-to-width, thank you Colin Walters.
+
2012-05-06 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/lisp-tests.el:
diff -r 0df4d95bd98a41c9a7826a307427e6f6dbcb9842 -r 00fd55d635fb2db4fb3b4647b1380769536f921c tests/automated/mule-tests.el
--- a/tests/automated/mule-tests.el
+++ b/tests/automated/mule-tests.el
@@ -808,7 +808,81 @@
(Assert (let (default-process-coding-system)
(shell-command "cat </dev/null >/dev/null")
t))))
-
+ ;;; Test suite for truncate-string-to-width, from Colin Walters' tests in
+ ;;; mult-util.el in GNU.
+ (macrolet
+ ((test-truncate-string-to-width (&rest tests)
+ (let ((decode-any-string
+ ;; We can't store the East Asian characters directly in this
+ ;; file, since it needs to be read (but not executed) by
+ ;; non-Mule. Store them as UTF-8, decode them at
+ ;; macro-expansion time.
+ #'(lambda (object)
+ (if (stringp object)
+ (decode-coding-string object 'utf-8)
+ object))))
+ (cons
+ 'progn
+ (mapcar
+ (function*
+ (lambda ((arguments . result))
+ `(Assert (equal (truncate-string-to-width
+ ,@(mapcar decode-any-string arguments))
+ ,(funcall decode-any-string result)))))
+ tests)))))
+ (test-truncate-string-to-width
+ (("" 0) . "")
+ (("x" 1) . "x")
+ (("xy" 1) . "x")
+ (("xy" 2 1) . "y")
+ (("xy" 0) . "")
+ (("xy" 3) . "xy")
+ (("\344\270\255" 0) . "")
+ (("\344\270\255" 1) . "")
+ (("\344\270\255" 2) . "\344\270\255")
+ (("\344\270\255" 1 nil ? ) . " ")
+ (("\344\270\255\346\226\207" 3 1 ? ) . " ")
+ (("x\344\270\255x" 2) . "x")
+ (("x\344\270\255x" 3) . "x\344\270\255")
+ (("x\344\270\255x" 3) . "x\344\270\255")
+ (("x\344\270\255x" 4 1) . "\344\270\255x")
+ (("kor\355\225\234e\352\270\200an" 8 1 ? ) .
+ "or\355\225\234e\352\270\200")
+ (("kor\355\225\234e\352\270\200an" 7 2 ? ) . "r\355\225\234e ")
+ (("" 0 nil nil "...") . "")
+ (("x" 3 nil nil "...") . "x")
+ (("\344\270\255" 3 nil nil "...") . "\344\270\255")
+ (("foo" 3 nil nil "...") . "foo")
+ (("foo" 2 nil nil "...") . "fo") ;; (old) XEmacs failure?
+ (("foobar" 6 0 nil "...") . "foobar")
+ (("foobarbaz" 6 nil nil "...") . "foo...")
+ (("foobarbaz" 7 2 nil "...") . "ob...")
+ (("foobarbaz" 9 3 nil "...") . "barbaz")
+ (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 15
+ 1 ? t) . " h\343\202\223e\343\201\253l\343\201\241l\343\201\257o")
+ (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 14
+ 1 ? t) . " h\343\202\223e\343\201\253l\343\201\241...")
+ (("x" 3 nil nil "\347\262\265\350\252\236") . "x")
+ (("\344\270\255" 2 nil nil "\347\262\265\350\252\236") . "\344\270\255")
+ ;; XEmacs used to error
+ (("\344\270\255" 1 nil ?x "\347\262\265\350\252\236") . "x")
+ (("\344\270\255\346\226\207" 3 nil ? "\347\262\265\350\252\236") .
+ ;; XEmacs used to error
+ "\344\270\255 ")
+ (("foobarbaz" 4 nil nil "\347\262\265\350\252\236") .
+ "\347\262\265\350\252\236")
+ (("foobarbaz" 5 nil nil "\347\262\265\350\252\236") .
+ "f\347\262\265\350\252\236")
+ (("foobarbaz" 6 nil nil "\347\262\265\350\252\236") .
+ "fo\347\262\265\350\252\236")
+ (("foobarbaz" 8 3 nil "\347\262\265\350\252\236") .
+ "b\347\262\265\350\252\236")
+ (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 14
+ 4 ?x "\346\227\245\346\234\254\350\252\236") .
+ "xe\343\201\253\346\227\245\346\234\254\350\252\236")
+ (("\343\201\223h\343\202\223e\343\201\253l\343\201\241l\343\201\257o" 13
+ 4 ?x "\346\227\245\346\234\254\350\252\236") .
+ "xex\346\227\245\346\234\254\350\252\236")))
) ; end of tests that require MULE built in.
;;; end of mule-tests.el
https://bitbucket.org/xemacs/xemacs/changeset/8593e614573a/
changeset: 8593e614573a
user: kehoea
date: 2012-05-12 19:12:13
summary: Avoid signalling args-out-of-range errors, #'truncate-string-to-width
lisp/ChangeLog addition:
Avoid args-out-of-range errors, this function is regularly called
from menu code and with debug-on-signal non-nil, this can be very
irritating.
Don't bind ellipsis-len, we don't use it.
affected #: 2 files
diff -r 00fd55d635fb2db4fb3b4647b1380769536f921c -r 8593e614573a4a167af4d3e73201dfa46c7e30a8 lisp/ChangeLog
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -3,6 +3,10 @@
* subr.el:
* subr.el (truncate-string-to-width):
Sync with GNU's version, use its test suite in mule-tests.el.
+ Avoid args-out-of-range errors, this function is regularly called
+ from menu code and with debug-on-signal non-nil, this can be very
+ irritating.
+ Don't bind ellipsis-len, we don't use it.
2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
diff -r 00fd55d635fb2db4fb3b4647b1380769536f921c -r 8593e614573a4a167af4d3e73201dfa46c7e30a8 lisp/subr.el
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1062,18 +1062,15 @@
(setq ellipsis "..."))
(let ((str-len (length str))
(str-width (string-width str))
- (ellipsis-len (if ellipsis (length ellipsis) 0))
(ellipsis-width (if ellipsis (string-width ellipsis) 0))
(idx 0)
(column 0)
(head-padding "") (tail-padding "")
ch last-column last-idx from-idx)
- (condition-case nil
- (while (< column start-column)
- (setq ch (aref str idx)
- column (+ column (char-width ch))
- idx (1+ idx)))
- (args-out-of-range (setq idx str-len)))
+ (while (and (< column start-column) (< idx str-len))
+ (setq ch (aref str idx)
+ column (+ column (char-width ch))
+ idx (1+ idx)))
(if (< column start-column)
(if padding (make-string end-column padding) "")
(when (and padding (> column start-column))
@@ -1084,14 +1081,12 @@
(> str-width ellipsis-width))
(setq end-column (- end-column ellipsis-width))
(setq ellipsis ""))
- (condition-case nil
- (while (< column end-column)
- (setq last-column column
- last-idx idx
- ch (aref str idx)
- column (+ column (char-width ch))
- idx (1+ idx)))
- (args-out-of-range (setq idx str-len)))
+ (while (and (< column end-column) (< idx str-len))
+ (setq last-column column
+ last-idx idx
+ ch (aref str idx)
+ column (+ column (char-width ch))
+ idx (1+ idx)))
(when (> column end-column)
(setq column last-column
idx last-idx))
Repository URL: https://bitbucket.org/xemacs/xemacs/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
[COMMIT] Fetch its bytecode before unfolding a compiled function, byte-optimize.el
12 years, 7 months
Aidan Kehoe
APPROVE COMMIT
NOTE: This patch has been committed.
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1336831404 -3600
# Node ID 0df4d95bd98a41c9a7826a307427e6f6dbcb9842
# Parent bed39edf91ba137860fa91f24628ff7bdecb43a1
Fetch its bytecode before unfolding a compiled function, byte-optimize.el
lisp/ChangeLog addition:
2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
* byte-optimize.el (byte-compile-unfold-lambda):
Fetch the bytecode before unfolding a compiled function, its body
may have been compiled lazily thanks to
byte-compile-dynamic. Thank you Mats Lidell and the package
smoketest!
diff -r bed39edf91ba -r 0df4d95bd98a lisp/ChangeLog
--- a/lisp/ChangeLog Thu May 10 13:53:06 2012 +0100
+++ b/lisp/ChangeLog Sat May 12 15:03:24 2012 +0100
@@ -1,3 +1,11 @@
+2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * byte-optimize.el (byte-compile-unfold-lambda):
+ Fetch the bytecode before unfolding a compiled function, its body
+ may have been compiled lazily thanks to
+ byte-compile-dynamic. Thank you Mats Lidell and the package
+ smoketest!
+
2012-05-10 Aidan Kehoe <kehoea(a)parhasard.net>
* mule/mule-category.el (word-combining-categories):
diff -r bed39edf91ba -r 0df4d95bd98a lisp/byte-optimize.el
--- a/lisp/byte-optimize.el Thu May 10 13:53:06 2012 +0100
+++ b/lisp/byte-optimize.el Sat May 12 15:03:24 2012 +0100
@@ -296,11 +296,12 @@
(let ((lambda (car form))
(values (cdr form)))
(if (compiled-function-p lambda)
- (setq lambda (list 'lambda (compiled-function-arglist lambda)
- (list 'byte-code
- (compiled-function-instructions lambda)
- (compiled-function-constants lambda)
- (compiled-function-stack-depth lambda)))))
+ (setq lambda (fetch-bytecode lambda)
+ lambda (list 'lambda (compiled-function-arglist lambda)
+ (list 'byte-code
+ (compiled-function-instructions lambda)
+ (compiled-function-constants lambda)
+ (compiled-function-stack-depth lambda)))))
(let ((arglist (nth 1 lambda))
(body (cdr (cdr lambda)))
optionalp restp
--
‘Iodine deficiency was endemic in parts of the UK until, through what has been
described as “an unplanned and accidental public health triumph”, iodine was
added to cattle feed to improve milk production in the 1930s.’
(EN Pearce, Lancet, June 2011)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
commit/XEmacs: kehoea: Fetch its bytecode before unfolding a compiled function, byte-optimize.el
12 years, 7 months
Bitbucket
1 new commit in XEmacs:
https://bitbucket.org/xemacs/xemacs/changeset/0df4d95bd98a/
changeset: 0df4d95bd98a
user: kehoea
date: 2012-05-12 16:03:24
summary: Fetch its bytecode before unfolding a compiled function, byte-optimize.el
lisp/ChangeLog addition:
2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
* byte-optimize.el (byte-compile-unfold-lambda):
Fetch the bytecode before unfolding a compiled function, its body
may have been compiled lazily thanks to
byte-compile-dynamic. Thank you Mats Lidell and the package
smoketest!
affected #: 2 files
diff -r bed39edf91ba137860fa91f24628ff7bdecb43a1 -r 0df4d95bd98a41c9a7826a307427e6f6dbcb9842 lisp/ChangeLog
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2012-05-12 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * byte-optimize.el (byte-compile-unfold-lambda):
+ Fetch the bytecode before unfolding a compiled function, its body
+ may have been compiled lazily thanks to
+ byte-compile-dynamic. Thank you Mats Lidell and the package
+ smoketest!
+
2012-05-10 Aidan Kehoe <kehoea(a)parhasard.net>
* mule/mule-category.el (word-combining-categories):
diff -r bed39edf91ba137860fa91f24628ff7bdecb43a1 -r 0df4d95bd98a41c9a7826a307427e6f6dbcb9842 lisp/byte-optimize.el
--- a/lisp/byte-optimize.el
+++ b/lisp/byte-optimize.el
@@ -296,11 +296,12 @@
(let ((lambda (car form))
(values (cdr form)))
(if (compiled-function-p lambda)
- (setq lambda (list 'lambda (compiled-function-arglist lambda)
- (list 'byte-code
- (compiled-function-instructions lambda)
- (compiled-function-constants lambda)
- (compiled-function-stack-depth lambda)))))
+ (setq lambda (fetch-bytecode lambda)
+ lambda (list 'lambda (compiled-function-arglist lambda)
+ (list 'byte-code
+ (compiled-function-instructions lambda)
+ (compiled-function-constants lambda)
+ (compiled-function-stack-depth lambda)))))
(let ((arglist (nth 1 lambda))
(body (cdr (cdr lambda)))
optionalp restp
Repository URL: https://bitbucket.org/xemacs/xemacs/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
commit/xemacs-packages: 3 new changesets
12 years, 7 months
Bitbucket
3 new commits in xemacs-packages:
https://bitbucket.org/xemacs/xemacs-packages/changeset/304f6bd4fc34/
changeset: 304f6bd4fc34
user: Norbert Koch
date: 2012-05-11 21:11:20
summary: Update xemacs-base
affected #: 1 file
diff -r 31e8227f15804846acdd87d43f92868976a5ae9d -r 304f6bd4fc345a4b65c556bba5377b7484e27678 .hgsubstate
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -123,7 +123,7 @@
4eb09b852b72373e7ce9790cb9ebafc7e1b7598e xemacs-packages/vm
59e99a00a59ffa39e51bb866ca30f2ec426459ee xemacs-packages/w3
fd7cd3bdb22b444b112299facd2375daa2091dee xemacs-packages/x-symbol
-d56f8e5d14021584dbef7f97c5985c36f19980cf xemacs-packages/xemacs-base
+080d3b71a1cc2953be541e3c57c4a9506ab05f63 xemacs-packages/xemacs-base
9c8d90ff018391ccc55abcf6967ea6a00e749f53 xemacs-packages/xemacs-devel
be5592eaca6a65548d138ecd753f2e71b123793a xemacs-packages/xetla
bc5e241f2ddfed169b3e679b85a030237d5132ee xemacs-packages/xlib
https://bitbucket.org/xemacs/xemacs-packages/changeset/88fd75e8fb26/
changeset: 88fd75e8fb26
user: Norbert Koch
date: 2012-05-11 21:11:42
summary: XEmacs Package Release
affected #: 1 file
diff -r 304f6bd4fc345a4b65c556bba5377b7484e27678 -r 88fd75e8fb2661511a39ce17b8aa882e115dcc14 ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-05-11 Norbert Koch <viteno(a)xemacs.org>
+
+ * Packages released: xemacs-base.
+
2012-05-11 Norbert Koch <viteno(a)xemacs.org>
* Packages released: w3.
https://bitbucket.org/xemacs/xemacs-packages/changeset/e72f7699b546/
changeset: e72f7699b546
user: Norbert Koch
date: 2012-05-11 21:16:41
summary: Prerelease xemacs-base
affected #: 1 file
diff -r 88fd75e8fb2661511a39ce17b8aa882e115dcc14 -r e72f7699b5466b57d4fd4ee3f8238c5600f788c9 .hgsubstate
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -123,7 +123,7 @@
4eb09b852b72373e7ce9790cb9ebafc7e1b7598e xemacs-packages/vm
59e99a00a59ffa39e51bb866ca30f2ec426459ee xemacs-packages/w3
fd7cd3bdb22b444b112299facd2375daa2091dee xemacs-packages/x-symbol
-080d3b71a1cc2953be541e3c57c4a9506ab05f63 xemacs-packages/xemacs-base
+190b20ac84fc380fba1dabcf04b0181f3ac13353 xemacs-packages/xemacs-base
9c8d90ff018391ccc55abcf6967ea6a00e749f53 xemacs-packages/xemacs-devel
be5592eaca6a65548d138ecd753f2e71b123793a xemacs-packages/xetla
bc5e241f2ddfed169b3e679b85a030237d5132ee xemacs-packages/xlib
Repository URL: https://bitbucket.org/xemacs/xemacs-packages/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
commit/xemacs-base: 2 new changesets
12 years, 7 months
Bitbucket
2 new commits in xemacs-base:
https://bitbucket.org/xemacs/xemacs-base/changeset/2d772818dd24/
changeset: 2d772818dd24
user: Norbert Koch
date: 2012-05-11 21:11:42
summary: XEmacs Package Release 2.32
affected #: 2 files
diff -r 080d3b71a1cc2953be541e3c57c4a9506ab05f63 -r 2d772818dd24876d728e60d0ca6b8903b6ac4ee0 ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-05-11 Norbert Koch <viteno(a)xemacs.org>
+
+ * Makefile (VERSION): XEmacs package 2.32 released.
+
2012-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
* advice.el (ad-pushnew-advised-function):
diff -r 080d3b71a1cc2953be541e3c57c4a9506ab05f63 -r 2d772818dd24876d728e60d0ca6b8903b6ac4ee0 Makefile
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-VERSION = 2.31
+VERSION = 2.32
AUTHOR_VERSION =
MAINTAINER = XEmacs Development Team <xemacs-beta(a)xemacs.org>
PACKAGE = xemacs-base
https://bitbucket.org/xemacs/xemacs-base/changeset/190b20ac84fc/
changeset: 190b20ac84fc
user: Norbert Koch
date: 2012-05-11 21:11:42
summary: Added tag xemacs-base-2_32 for changeset 2d772818dd24
affected #: 1 file
diff -r 2d772818dd24876d728e60d0ca6b8903b6ac4ee0 -r 190b20ac84fc380fba1dabcf04b0181f3ac13353 .hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -151,3 +151,4 @@
cac1b35311d72a448d046d13ff7b6eeb750f0a98 xemacs-base-1_40
180d3329330918504ae165892e3fb92edc3d7efa xemacs-base-1_41
a0a1d78982e41ca066dc5aed5dc1a5009f60a091 xemacs-base-2_31
+2d772818dd24876d728e60d0ca6b8903b6ac4ee0 xemacs-base-2_32
Repository URL: https://bitbucket.org/xemacs/xemacs-base/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
[COMMIT XEMACS-BASE] Use standard backquotes, advice.el, old Emacs Lisp backquotes are long obsolete.
12 years, 7 months
Aidan Kehoe
APPROVE COMMIT
NOTE: This patch has been committed.
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1336760515 -3600
# Node ID 080d3b71a1cc2953be541e3c57c4a9506ab05f63
# Parent 51d722692ee03cc29c3a708e66e4b46dc164a117
Use standard backquotes, advice.el, old Emacs Lisp backquotes are long obsolete.
diff -r 51d722692ee0 -r 080d3b71a1cc ChangeLog
--- a/ChangeLog Fri May 11 17:41:54 2012 +0100
+++ b/ChangeLog Fri May 11 19:21:55 2012 +0100
@@ -60,6 +60,8 @@
Uncomment the docstrings for these functions, they take up negligible
space these days.
+ Use standard backquotes, old Emacs Lisp backquotes are long obsolete.
+
2012-01-10 Norbert Koch <viteno(a)xemacs.org>
* Makefile (VERSION): XEmacs package 2.31 released.
diff -r 51d722692ee0 -r 080d3b71a1cc advice.el
--- a/advice.el Fri May 11 17:41:54 2012 +0100
+++ b/advice.el Fri May 11 19:21:55 2012 +0100
@@ -1731,7 +1731,7 @@
;; `ad-return-value' in a piece of after advice. For example:
;;
;; (defmacro foom (x)
-;; (` (list (, x))))
+;; `(list ,x))
;; foom
;;
;; (foom '(a))
@@ -1763,9 +1763,7 @@
;;
;; (defadvice foom (after fg-print-x act)
;; "Print the value of X."
-;; (setq ad-return-value
-;; (` (progn (print (, x))
-;; (, ad-return-value)))))
+;; (setq ad-return-value `(progn (print ,x) ,ad-return-value)))
;; foom
;;
;; (macroexpand '(foom '(a)))
@@ -1879,15 +1877,15 @@
(let ((saved-function (intern (format "ad-real-%s" function))))
;; Make sure the compiler is loaded during macro expansion:
(require 'byte-compile "bytecomp")
- (` (if (not (fboundp '(, saved-function)))
- (progn (fset '(, saved-function) (symbol-function '(, function)))
- ;; Copy byte-compiler properties:
- (,@ (if (get function 'byte-compile)
- (` ((put '(, saved-function) 'byte-compile
- '(, (get function 'byte-compile)))))))
- (,@ (if (get function 'byte-opcode)
- (` ((put '(, saved-function) 'byte-opcode
- '(, (get function 'byte-opcode))))))))))))
+ `(if (not (fboundp ',saved-function))
+ (progn (fset ',saved-function (symbol-function ',function))
+ ;; Copy byte-compiler properties:
+ ,@(if (get function 'byte-compile)
+ `((put ',saved-function 'byte-compile
+ ',(get function 'byte-compile))))
+ ,@(if (get function 'byte-opcode)
+ `((put ',saved-function 'byte-opcode
+ ',(get function 'byte-opcode))))))))
(defun ad-save-real-definitions ()
;; Macro expansion will hardcode the values of the various byte-compiler
@@ -1923,16 +1921,15 @@
(defmacro ad-pushnew-advised-function (function)
"Add FUNCTION to `ad-advised-functions' unless its already there."
- (` (if (not (assoc (symbol-name (, function)) ad-advised-functions))
- (setq ad-advised-functions
- (cons (list (symbol-name (, function)))
- ad-advised-functions)))))
+ `(if (not (assoc (symbol-name ,function) ad-advised-functions))
+ (setq ad-advised-functions
+ (cons (list (symbol-name ,function)) ad-advised-functions))))
(defmacro ad-pop-advised-function (function)
"Remove FUNCTION from `ad-advised-functions'."
- (` (setq ad-advised-functions
- (delq (assoc (symbol-name (, function)) ad-advised-functions)
- ad-advised-functions))))
+ `(setq ad-advised-functions
+ (delq (assoc (symbol-name ,function) ad-advised-functions)
+ ad-advised-functions)))
(defmacro ad-do-advised-functions (varform &rest body)
"`dolist'-style iterator that maps over `ad-advised-functions'.
@@ -1940,23 +1937,21 @@
BODY-FORM...)
Also see `dolist'. On each iteration VAR will be bound to the
name of an advised function (a symbol)."
- (` (dolist ((, (car varform))
- ad-advised-functions
- (, (car (cdr varform))))
- (setq (, (car varform)) (intern (car (, (car varform)))))
- (,@ body))))
+ `(dolist (,(car varform) ad-advised-functions ,(car (cdr varform)))
+ (setq ,(car varform) (intern (car ,(car varform))))
+ ,@body))
(if (not (get 'ad-do-advised-functions 'lisp-indent-hook))
(put 'ad-do-advised-functions 'lisp-indent-hook 1))
(defmacro ad-get-advice-info (function)
- (` (get (, function) 'ad-advice-info)))
+ `(get ,function 'ad-advice-info))
(defmacro ad-set-advice-info (function advice-info)
- (` (put (, function) 'ad-advice-info (, advice-info))))
+ `(put ,function 'ad-advice-info ,advice-info))
(defmacro ad-copy-advice-info (function)
- (` (copy-tree (get (, function) 'ad-advice-info))))
+ `(copy-tree (get ,function 'ad-advice-info)))
(defmacro ad-is-advised (function)
"Return non-nil if FUNCTION has any advice info associated with it.
@@ -1971,7 +1966,7 @@
(defmacro ad-get-advice-info-field (function field)
"Retrieves the value of the advice info FIELD of FUNCTION."
- (` (cdr (assq (, field) (ad-get-advice-info (, function))))))
+ `(cdr (assq ,field (ad-get-advice-info ,function))))
(defun ad-set-advice-info-field (function field value)
"Destructively modifies VALUE of the advice info FIELD of FUNCTION."
@@ -2097,8 +2092,8 @@
(defvar ad-activate-on-top-level t)
(defmacro ad-with-auto-activation-disabled (&rest body)
- (` (let ((ad-activate-on-top-level nil))
- (,@ body))))
+ `(let ((ad-activate-on-top-level nil))
+ ,@body))
(defun ad-safe-fset (symbol definition)
"A safe `fset' which will never call `ad-activate' recursively."
@@ -2120,17 +2115,14 @@
(intern (format "ad-Orig-%s" function)))
(defmacro ad-get-orig-definition (function)
- (` (let ((origname (ad-get-advice-info-field (, function) 'origname)))
- (if (fboundp origname)
- (symbol-function origname)))))
+ `(let ((origname (ad-get-advice-info-field ,function 'origname)))
+ (if (fboundp origname) (symbol-function origname))))
(defmacro ad-set-orig-definition (function definition)
- (` (ad-safe-fset
- (ad-get-advice-info-field function 'origname) (, definition))))
+ `(ad-safe-fset (ad-get-advice-info-field function 'origname) ,definition))
(defmacro ad-clear-orig-definition (function)
- (` (fmakunbound (ad-get-advice-info-field (, function) 'origname))))
-
+ `(fmakunbound (ad-get-advice-info-field ,function 'origname)))
;; @@ Interactive input functions:
;; ===============================
@@ -2237,7 +2229,7 @@
(defmacro ad-find-advice (function class name)
"Find the first advice of FUNCTION in CLASS with NAME."
- (` (assq (, name) (ad-get-advice-info-field (, function) (, class)))))
+ `(assq ,name (ad-get-advice-info-field ,function ,class)))
(defun ad-advice-position (function class name)
"Return position of first advice of FUNCTION in CLASS with NAME."
@@ -2266,12 +2258,12 @@
(if found-advice (return found-advice))))))
(defun ad-enable-advice-internal (function class name flag)
- ;;"Sets enable FLAG of FUNCTION's advices in CLASS matching NAME.
- ;;If NAME is a string rather than a symbol then it's interpreted as a regular
- ;;expression and all advices whose name contain a match for it will be
- ;;affected. If CLASS is `any' advices in all legal advice classes will be
- ;;considered. The number of changed advices will be returned (or nil if
- ;;FUNCTION was not advised)."
+ "Set enable FLAG of FUNCTION's advices in CLASS matching NAME.
+If NAME is a string rather than a symbol then it's interpreted as a regular
+expression and all advices whose name contain a match for it will be
+affected. If CLASS is `any' advices in all legal advice classes will be
+considered. The number of changed advices will be returned (or nil if
+FUNCTION was not advised)."
(if (ad-is-advised function)
(let ((matched-advices 0))
(dolist (advice-class ad-advice-classes)
@@ -2394,33 +2386,33 @@
;; ===================================================
(defmacro ad-macrofy (definition)
- ;;"Takes a lambda function DEFINITION and makes a macro out of it."
- (` (cons 'macro (, definition))))
+ "Take a lambda function DEFINITION and make a macro out of it."
+ `(cons 'macro ,definition))
(defmacro ad-lambdafy (definition)
- ;;"Takes a macro function DEFINITION and makes a lambda out of it."
- (` (cdr (, definition))))
+ "Take a macro function DEFINITION and make a lambda out of it."
+ `(cdr ,definition))
(defmacro ad-interactive-p (definition)
- ;;"non-nil if DEFINITION can be called interactively."
+ "Non-nil if DEFINITION can be called interactively."
(list 'commandp definition))
(defmacro ad-subr-p (definition)
- ;;"non-nil if DEFINITION is a subr."
+ "Non-nil if DEFINITION is a subr."
(list 'subrp definition))
(defmacro ad-macro-p (definition)
- ;;"non-nil if DEFINITION is a macro."
- (` (eq (car-safe (, definition)) 'macro)))
+ "Non-nil if DEFINITION is a macro."
+ `(eq (car-safe ,definition) 'macro))
(defmacro ad-lambda-p (definition)
- ;;"non-nil if DEFINITION is a lambda expression."
- (` (eq (car-safe (, definition)) 'lambda)))
+ "Non-nil if DEFINITION is a lambda expression."
+ `(eq (car-safe ,definition) 'lambda))
;; see ad-make-advice for the format of advice definitions:
(defmacro ad-advice-p (definition)
- ;;"non-nil if DEFINITION is a piece of advice."
- (` (eq (car-safe (, definition)) 'advice)))
+ "Non-nil if DEFINITION is a piece of advice."
+ `(eq (car-safe ,definition) 'advice))
;; Emacs/XEmacs cross-compatibility
;; (compiled-function-p is an obsolete function in Emacs):
@@ -2430,15 +2422,15 @@
(defmacro ad-compiled-p (definition)
"Return non-nil if DEFINITION is a compiled byte-code object."
- (` (or (byte-code-function-p (, definition))
- (and (ad-macro-p (, definition))
- (byte-code-function-p (ad-lambdafy (, definition)))))))
+ `(or (byte-code-function-p ,definition)
+ (and (ad-macro-p ,definition)
+ (byte-code-function-p (ad-lambdafy ,definition)))))
(defmacro ad-compiled-code (compiled-definition)
"Return the byte-code object of a COMPILED-DEFINITION."
- (` (if (ad-macro-p (, compiled-definition))
- (ad-lambdafy (, compiled-definition))
- (, compiled-definition))))
+ `(if (ad-macro-p ,compiled-definition)
+ (ad-lambdafy ,compiled-definition)
+ ,compiled-definition))
(defun ad-lambda-expression (definition)
"Return the lambda expression of a function/macro/advice DEFINITION."
@@ -2473,13 +2465,13 @@
;; Store subr-args as `((arg1 arg2 ...))' so I can distinguish
;; a defined empty arglist `(nil)' from an undefined arglist:
(defmacro ad-define-subr-args (subr arglist)
- (` (put (, subr) 'ad-subr-arglist (list (, arglist)))))
+ `(put ,subr 'ad-subr-arglist (list ,arglist)))
(defmacro ad-undefine-subr-args (subr)
- (` (put (, subr) 'ad-subr-arglist nil)))
+ `(put ,subr 'ad-subr-arglist nil))
(defmacro ad-subr-args-defined-p (subr)
- (` (get (, subr) 'ad-subr-arglist)))
+ `(get ,subr 'ad-subr-arglist))
(defmacro ad-get-subr-args (subr)
- (` (car (get (, subr) 'ad-subr-arglist))))
+ `(car (get ,subr 'ad-subr-arglist)))
(defun ad-subr-arglist (subr-name)
"Retrieve arglist of the subr with SUBR-NAME.
@@ -2688,18 +2680,12 @@
element is its actual current value, and the third element is either
`required', `optional' or `rest' depending on the type of the argument."
(let* ((parsed-arglist (ad-parse-arglist arglist))
- (rest (nth 2 parsed-arglist)))
- (` (list
- (,@ (mapcar (function
- (lambda (req)
- (` (list '(, req) (, req) 'required))))
- (nth 0 parsed-arglist)))
- (,@ (mapcar (function
- (lambda (opt)
- (` (list '(, opt) (, opt) 'optional))))
- (nth 1 parsed-arglist)))
- (,@ (if rest (list (` (list '(, rest) (, rest) 'rest)))))
- ))))
+ (rest (nth 2 parsed-arglist)))
+ `(list ,@(mapcar #'(lambda (req) `(list ',req ,req 'required))
+ (nth 0 parsed-arglist))
+ ,@(mapcar #'(lambda (opt) `(list ',opt ,opt 'optional))
+ (nth 1 parsed-arglist))
+ ,@(if rest (list `(list ',rest ,rest 'rest))))))
(defun ad-arg-binding-field (binding field)
(cond ((eq field 'name) (car binding))
@@ -2713,7 +2699,7 @@
(defun ad-element-access (position list)
(cond ((= position 0) (list 'car list))
- ((= position 1) (` (car (cdr (, list)))))
+ ((= position 1) `(car (cdr ,list)))
(t (list 'nth position list))))
(defun ad-access-argument (arglist index)
@@ -2742,13 +2728,15 @@
(let ((argument-access (ad-access-argument arglist index)))
(cond ((consp argument-access)
;; should this check whether there actually is something to set?
- (` (setcar (, (ad-list-access
- (car argument-access) (car (cdr argument-access))))
- (, value-form))))
- (argument-access
- (` (setq (, argument-access) (, value-form))))
- (t (error "ad-set-argument: No argument at position %d of `%s'"
- index arglist)))))
+ `(setcar ,(ad-list-access (car argument-access)
+ (car (cdr argument-access)))
+ ,value-form))
+ (argument-access `(setq ,argument-access ,value-form))
+ (t
+ (error
+ "ad-set-argument: No argument at position %d of `%s'"
+ index
+ arglist)))))
(defun ad-get-arguments (arglist index)
"Returns form to access all actual arguments starting at position INDEX."
@@ -2758,12 +2746,13 @@
(rest-arg (nth 2 parsed-arglist))
args-form)
(if (< index (length reqopt-args))
- (setq args-form (` (list (,@ (nthcdr index reqopt-args))))))
+ (setq args-form `(list ,@(nthcdr index reqopt-args))))
(if rest-arg
- (if args-form
- (setq args-form (` (nconc (, args-form) (, rest-arg))))
- (setq args-form (ad-list-access (- index (length reqopt-args))
- rest-arg))))
+ (if args-form
+ (setq args-form `(nconc ,args-form ,rest-arg))
+ (setq
+ args-form
+ (ad-list-access (- index (length reqopt-args)) rest-arg))))
args-form))
(defun ad-set-arguments (arglist index values-form)
@@ -2799,10 +2788,10 @@
;; For exactly one set-form we can use values-form directly,...
(subst values-form 'ad-vAlUeS (car set-forms))
;; ...if we have more we have to bind it to a variable:
- (` (let ((ad-vAlUeS (, values-form)))
- (,@ (reverse set-forms))
- ;; work around the old backquote bug:
- (, 'ad-vAlUeS)))))))
+ `(let ((ad-vAlUeS ,values-form))
+ ,@(reverse set-forms)
+ ;; work around the old backquote bug:
+ ,'ad-vAlUeS)))))
(defun ad-insert-argument-access-forms (definition arglist)
"Expand arg-access text macros in DEFINITION according to ARGLIST."
@@ -3007,11 +2996,11 @@
;; we have to and initialize required arguments in case
;; it is called interactively:
(orig-interactive-p
- (let ((reqargs (car (ad-parse-arglist advised-arglist))))
- (if reqargs
- (` (interactive
- '(, (make-list (length reqargs) nil))))
- '(interactive))))))
+ (let ((reqargs
+ (car (ad-parse-arglist advised-arglist))))
+ (if reqargs
+ `(interactive ',(make-list (length reqargs) nil))
+ '(interactive))))))
(orig-form
(cond ((or orig-special-form-p orig-macro-p)
;; Special forms and macros will be advised into macros.
@@ -3028,20 +3017,18 @@
;; expansion time and return the result. The moral of that
;; is that one should always deactivate advised special
;; forms before one byte-compiles a file.
- (` ((, (if orig-macro-p
- 'macroexpand
- 'eval))
- (cons '(, origname)
- (, (ad-get-arguments advised-arglist 0))))))
- ((and orig-subr-p
- orig-interactive-p
- (not advised-interactive-form))
+ `(,(if orig-macro-p 'macroexpand 'eval)
+ (cons ',origname
+ ,(ad-get-arguments advised-arglist 0))))
+ ((and orig-subr-p
+ orig-interactive-p
+ (not advised-interactive-form))
;; Check whether we were called interactively
;; in order to do proper prompting:
- (` (if (interactive-p)
- (call-interactively '(, origname))
- (, (ad-make-mapped-call
- orig-arglist advised-arglist origname)))))
+ `(if (interactive-p)
+ (call-interactively ',origname)
+ ,(ad-make-mapped-call orig-arglist advised-arglist
+ origname)))
;; And now for normal functions and non-interactive subrs
;; (or subrs whose interactive behavior was advised):
(t (ad-make-mapped-call
@@ -3074,18 +3061,16 @@
(let (before-forms around-form around-form-protected after-forms definition)
(dolist (advice befores)
- (cond ((and (ad-advice-protected advice)
- before-forms)
- (setq before-forms
- (` ((unwind-protect
- (, (ad-prognify before-forms))
- (,@ (ad-body-forms
- (ad-advice-definition advice))))))))
- (t (setq before-forms
- (append before-forms
- (ad-body-forms (ad-advice-definition advice)))))))
-
- (setq around-form (` (setq ad-return-value (, orig))))
+ (cond ((and (ad-advice-protected advice) before-forms)
+ (setq before-forms
+ `((unwind-protect
+ ,(ad-prognify before-forms)
+ ,@(ad-body-forms (ad-advice-definition advice))))))
+ (t
+ (setq before-forms
+ (append before-forms
+ (ad-body-forms (ad-advice-definition advice)))))))
+ (setq around-form `(setq ad-return-value ,orig))
(dolist (advice (reverse arounds))
;; If any of the around advices is protected then we
;; protect the complete around advice onion:
@@ -3096,35 +3081,27 @@
(ad-prognify
(ad-body-forms (ad-advice-definition advice))))))
(setq after-forms
- (if (and around-form-protected before-forms)
- (` ((unwind-protect
- (, (ad-prognify before-forms))
- (, around-form))))
- (append before-forms (list around-form))))
+ (if (and around-form-protected before-forms)
+ `((unwind-protect ,(ad-prognify before-forms) ,around-form))
+ (append before-forms (list around-form))))
(dolist (advice afters)
- (cond ((and (ad-advice-protected advice)
- after-forms)
- (setq after-forms
- (` ((unwind-protect
- (, (ad-prognify after-forms))
- (,@ (ad-body-forms
- (ad-advice-definition advice))))))))
- (t (setq after-forms
- (append after-forms
- (ad-body-forms (ad-advice-definition advice)))))))
-
+ (cond ((and (ad-advice-protected advice) after-forms)
+ (setq after-forms
+ `((unwind-protect ,(ad-prognify after-forms)
+ ,@(ad-body-forms (ad-advice-definition advice))))))
+ (t
+ (setq after-forms
+ (append after-forms
+ (ad-body-forms (ad-advice-definition advice)))))))
(setq definition
- (` ((,@ (if (memq type '(macro special-form)) '(macro)))
- lambda
- (, args)
- (,@ (if docstring (list docstring)))
- (,@ (if interactive (list interactive)))
- (let (ad-return-value)
- (,@ after-forms)
- (, (if (eq type 'special-form)
- '(list 'quote ad-return-value)
- 'ad-return-value))))))
-
+ `(,@(if (memq type '(macro special-form)) '(macro))
+ lambda ,args ,@(if docstring (list docstring))
+ ,@(if interactive (list interactive))
+ (let (ad-return-value)
+ ,@after-forms
+ ,(if (eq type 'special-form)
+ '(list 'quote ad-return-value)
+ 'ad-return-value))))
(ad-insert-argument-access-forms definition args)))
;; This is needed for activation/deactivation hooks:
@@ -3199,14 +3176,13 @@
;; a lot cheaper than reconstructing an advised definition.
(defmacro ad-get-cache-definition (function)
- (` (car (ad-get-advice-info-field (, function) 'cache))))
+ `(car (ad-get-advice-info-field ,function 'cache)))
(defmacro ad-get-cache-id (function)
- (` (cdr (ad-get-advice-info-field (, function) 'cache))))
+ `(cdr (ad-get-advice-info-field ,function 'cache)))
(defmacro ad-set-cache (function definition id)
- (` (ad-set-advice-info-field
- (, function) 'cache (cons (, definition) (, id)))))
+ `(ad-set-advice-info-field ,function 'cache (cons ,definition ,id)))
(defun ad-clear-cache (function)
"Clears a previously cached advised definition of FUNCTION.
@@ -3407,20 +3383,17 @@
(ad-safe-fset 'ad-make-origname real-origname-fn))))
(if frozen-definition
(let* ((macro-p (ad-macro-p frozen-definition))
- (body (cdr (if macro-p
- (ad-lambdafy frozen-definition)
- frozen-definition))))
- (` (progn
- (if (not (fboundp '(, unique-origname)))
- (fset '(, unique-origname)
- ;; avoid infinite recursion in case the function
- ;; we want to freeze is already advised:
- (or (ad-get-orig-definition '(, function))
- (symbol-function '(, function)))))
- ((, (if macro-p 'defmacro 'defun))
- (, function)
- (,@ body))))))))
-
+ (body (cdr (if macro-p
+ (ad-lambdafy frozen-definition)
+ frozen-definition))))
+ `(progn
+ (if (not (fboundp ',unique-origname))
+ ;; avoid infinite recursion in case the function
+ ;; we want to freeze is already advised:
+ (fset ',unique-origname
+ (or (ad-get-orig-definition ',function)
+ (symbol-function ',function))))
+ (,(if macro-p 'defmacro 'defun) ,function ,@body))))))
;; @@ Activation and definition handling:
;; ======================================
@@ -3552,7 +3525,7 @@
(t (ad-deactivate function)))))))))
(defun ad-deactivate (function)
- "Deactivates the advice of an actively advised FUNCTION.
+ "Deactivate the advice of an actively advised FUNCTION.
If FUNCTION has a proper original definition, then the current
definition of FUNCTION will be replaced with it. All the advice
information will still be available so it can be activated again with
@@ -3755,10 +3728,9 @@
(t (error "defadvice: Illegal or ambiguous flag: %s"
flag))))))
args))
- (advice (ad-make-advice
- name (memq 'protect flags)
- (not (memq 'disable flags))
- (` (advice lambda (, arglist) (,@ body)))))
+ (advice (ad-make-advice name (memq 'protect flags)
+ (not (memq 'disable flags))
+ `(advice lambda ,arglist ,@body)))
(preactivation (if (memq 'preactivate flags)
(ad-preactivate-advice
function advice class position))))
@@ -3766,27 +3738,21 @@
(if (memq 'freeze flags)
;; jwz's idea: Freeze the advised definition into a dumpable
;; defun/defmacro whose docs can be written to the DOC file:
- (ad-make-freeze-definition function advice class position)
- ;; the normal case:
- (` (progn
- (ad-add-advice '(, function) '(, advice) '(, class) '(, position))
- (,@ (if preactivation
- (` ((ad-set-cache
- '(, function)
- ;; the function will get compiled:
- (, (cond ((ad-macro-p (car preactivation))
- (` (ad-macrofy
- (function
- (, (ad-lambdafy
- (car preactivation)))))))
- (t (` (function
- (, (car preactivation)))))))
- '(, (car (cdr preactivation))))))))
- (,@ (if (memq 'activate flags)
- (` ((ad-activate-on '(, function)
- (, (if (memq 'compile flags) t)))))))
- '(, function))))))
-
+ (ad-make-freeze-definition function advice class position)
+ ;; the normal case:
+ `(progn (ad-add-advice ',function ',advice ',class ',position)
+ ,@(if preactivation
+ `((ad-set-cache
+ ',function
+ ,(cond ((ad-macro-p (car preactivation))
+ `(ad-macrofy
+ #',(ad-lambdafy (car preactivation))))
+ (t `#',(car preactivation)))
+ ',(car (cdr preactivation)))))
+ ,@(if (memq 'activate flags)
+ `((ad-activate-on ',function
+ ,(if (memq 'compile flags) t))))
+ ',function))))
;; @@ Tools:
;; =========
@@ -3801,39 +3767,35 @@
(current-bindings
(mapcar (function
(lambda (function)
- (setq index (1+ index))
- (list (intern (format "ad-oRiGdEf-%d" index))
- (` (symbol-function '(, function))))))
+ (setq index (1+ index))
+ (list
+ (intern (format "ad-oRiGdEf-%d" index))
+ `(symbol-function ',function))))
functions)))
- (` (let (, current-bindings)
- (unwind-protect
- (progn
- (,@ (progn
+ `(let ,current-bindings
+ (unwind-protect
+ (progn ,@(progn
;; Make forms to redefine functions to their
;; original definitions if they are advised:
- (setq index -1)
- (mapcar
- (function
- (lambda (function)
- (setq index (1+ index))
- (` (ad-safe-fset
- '(, function)
- (or (ad-get-orig-definition '(, function))
- (, (car (nth index current-bindings))))))))
- functions)))
- (,@ body))
- (,@ (progn
- ;; Make forms to back-define functions to the definitions
- ;; they had outside this macro call:
- (setq index -1)
- (mapcar
- (function
- (lambda (function)
- (setq index (1+ index))
- (` (ad-safe-fset
- '(, function)
- (, (car (nth index current-bindings)))))))
- functions))))))))
+ (setq index -1)
+ (mapcar
+ #'(lambda (function)
+ (setq index (1+ index))
+ `(ad-safe-fset ',function
+ (or (ad-get-orig-definition ',function)
+ ,(car (nth index current-bindings)))))
+ functions))
+ ,@body)
+ ,@(progn
+ ;; Make forms to back-define functions to the definitions
+ ;; they had outside this macro call:
+ (setq index -1)
+ (mapcar
+ #'(lambda (function)
+ (setq index (1+ index))
+ `(ad-safe-fset ',function
+ ,(car (nth index current-bindings))))
+ functions))))))
(if (not (get 'ad-with-originals 'lisp-indent-hook))
(put 'ad-with-originals 'lisp-indent-hook 1))
--
‘Iodine deficiency was endemic in parts of the UK until, through what has been
described as “an unplanned and accidental public health triumph”, iodine was
added to cattle feed to improve milk production in the 1930s.’
(EN Pearce, Lancet, June 2011)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
[COMMIT XEMACS-BASE] Uncomment docstrings, advice.el.
12 years, 7 months
Aidan Kehoe
APPROVE COMMIT
NOTE: This patch has been committed.
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1336754514 -3600
# Node ID 51d722692ee03cc29c3a708e66e4b46dc164a117
# Parent d56f8e5d14021584dbef7f97c5985c36f19980cf
Uncomment docstrings, advice.el.
2012-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
* advice.el (ad-pushnew-advised-function):
* advice.el (ad-pop-advised-function):
* advice.el (ad-do-advised-functions):
* advice.el (ad-is-advised):
* advice.el (ad-initialize-advice-info):
* advice.el (ad-get-advice-info-field):
* advice.el (ad-set-advice-info-field):
* advice.el (ad-is-active):
* advice.el (ad-has-enabled-advice):
* advice.el (ad-has-redefining-advice):
* advice.el (ad-has-any-advice):
* advice.el (ad-get-enabled-advices):
* advice.el (ad-safe-fset):
* advice.el (ad-make-origname):
* advice.el (ad-read-advised-function):
* advice.el (ad-read-advice-class):
* advice.el (ad-read-advice-name):
* advice.el (ad-read-advice-specification):
* advice.el (ad-read-regexp):
* advice.el (ad-find-advice):
* advice.el (ad-advice-position):
* advice.el (ad-compiled-p):
* advice.el (ad-compiled-code):
* advice.el (ad-lambda-expression):
* advice.el (ad-arglist):
* advice.el (ad-subr-arglist):
* advice.el (ad-docstring):
* advice.el (ad-interactive-form):
* advice.el (ad-body-forms):
* advice.el (ad-make-advised-definition-docstring):
* advice.el (ad-advised-definition-p):
* advice.el (ad-definition-type):
* advice.el (ad-has-proper-definition):
* advice.el (ad-real-definition):
* advice.el (ad-real-orig-definition):
* advice.el (ad-is-compilable):
* advice.el (ad-compile-function):
* advice.el (ad-parse-arglist):
* advice.el (ad-retrieve-args-form):
* advice.el (ad-access-argument):
* advice.el (ad-get-argument):
* advice.el (ad-set-argument):
* advice.el (ad-get-arguments):
* advice.el (ad-set-arguments):
* advice.el (ad-insert-argument-access-forms):
* advice.el (ad-make-mapped-call):
* advice.el (ad-make-advised-docstring):
* advice.el (ad-advised-arglist):
* advice.el (ad-advised-interactive-form):
* advice.el (ad-make-advised-definition):
* advice.el (ad-make-hook-form):
* advice.el (ad-make-cache-id):
* advice.el (ad-get-cache-class-id):
* advice.el (ad-verify-cache-id):
* advice.el (ad-preactivate-advice):
* advice.el (ad-should-compile):
* advice.el (ad-activate-advised-definition):
Uncomment the docstrings for these functions, they take up negligible
space these days.
diff -r d56f8e5d1402 -r 51d722692ee0 ChangeLog
--- a/ChangeLog Tue Jan 10 14:53:48 2012 +0100
+++ b/ChangeLog Fri May 11 17:41:54 2012 +0100
@@ -1,3 +1,65 @@
+2012-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * advice.el (ad-pushnew-advised-function):
+ * advice.el (ad-pop-advised-function):
+ * advice.el (ad-do-advised-functions):
+ * advice.el (ad-is-advised):
+ * advice.el (ad-initialize-advice-info):
+ * advice.el (ad-get-advice-info-field):
+ * advice.el (ad-set-advice-info-field):
+ * advice.el (ad-is-active):
+ * advice.el (ad-has-enabled-advice):
+ * advice.el (ad-has-redefining-advice):
+ * advice.el (ad-has-any-advice):
+ * advice.el (ad-get-enabled-advices):
+ * advice.el (ad-safe-fset):
+ * advice.el (ad-make-origname):
+ * advice.el (ad-read-advised-function):
+ * advice.el (ad-read-advice-class):
+ * advice.el (ad-read-advice-name):
+ * advice.el (ad-read-advice-specification):
+ * advice.el (ad-read-regexp):
+ * advice.el (ad-find-advice):
+ * advice.el (ad-advice-position):
+ * advice.el (ad-compiled-p):
+ * advice.el (ad-compiled-code):
+ * advice.el (ad-lambda-expression):
+ * advice.el (ad-arglist):
+ * advice.el (ad-subr-arglist):
+ * advice.el (ad-docstring):
+ * advice.el (ad-interactive-form):
+ * advice.el (ad-body-forms):
+ * advice.el (ad-make-advised-definition-docstring):
+ * advice.el (ad-advised-definition-p):
+ * advice.el (ad-definition-type):
+ * advice.el (ad-has-proper-definition):
+ * advice.el (ad-real-definition):
+ * advice.el (ad-real-orig-definition):
+ * advice.el (ad-is-compilable):
+ * advice.el (ad-compile-function):
+ * advice.el (ad-parse-arglist):
+ * advice.el (ad-retrieve-args-form):
+ * advice.el (ad-access-argument):
+ * advice.el (ad-get-argument):
+ * advice.el (ad-set-argument):
+ * advice.el (ad-get-arguments):
+ * advice.el (ad-set-arguments):
+ * advice.el (ad-insert-argument-access-forms):
+ * advice.el (ad-make-mapped-call):
+ * advice.el (ad-make-advised-docstring):
+ * advice.el (ad-advised-arglist):
+ * advice.el (ad-advised-interactive-form):
+ * advice.el (ad-make-advised-definition):
+ * advice.el (ad-make-hook-form):
+ * advice.el (ad-make-cache-id):
+ * advice.el (ad-get-cache-class-id):
+ * advice.el (ad-verify-cache-id):
+ * advice.el (ad-preactivate-advice):
+ * advice.el (ad-should-compile):
+ * advice.el (ad-activate-advised-definition):
+ Uncomment the docstrings for these functions, they take up negligible
+ space these days.
+
2012-01-10 Norbert Koch <viteno(a)xemacs.org>
* Makefile (VERSION): XEmacs package 2.31 released.
diff -r d56f8e5d1402 -r 51d722692ee0 advice.el
--- a/advice.el Tue Jan 10 14:53:48 2012 +0100
+++ b/advice.el Fri May 11 17:41:54 2012 +0100
@@ -1922,24 +1922,24 @@
(defvar ad-advised-functions nil)
(defmacro ad-pushnew-advised-function (function)
- ;;"Add FUNCTION to `ad-advised-functions' unless its already there."
+ "Add FUNCTION to `ad-advised-functions' unless its already there."
(` (if (not (assoc (symbol-name (, function)) ad-advised-functions))
(setq ad-advised-functions
(cons (list (symbol-name (, function)))
ad-advised-functions)))))
(defmacro ad-pop-advised-function (function)
- ;;"Remove FUNCTION from `ad-advised-functions'."
+ "Remove FUNCTION from `ad-advised-functions'."
(` (setq ad-advised-functions
(delq (assoc (symbol-name (, function)) ad-advised-functions)
ad-advised-functions))))
(defmacro ad-do-advised-functions (varform &rest body)
- ;;"`dolist'-style iterator that maps over `ad-advised-functions'.
- ;; (ad-do-advised-functions (VAR [RESULT-FORM])
- ;; BODY-FORM...)
- ;;Also see `dolist'. On each iteration VAR will be bound to the
- ;;name of an advised function (a symbol)."
+ "`dolist'-style iterator that maps over `ad-advised-functions'.
+ (ad-do-advised-functions (VAR [RESULT-FORM])
+ BODY-FORM...)
+Also see `dolist'. On each iteration VAR will be bound to the
+name of an advised function (a symbol)."
(` (dolist ((, (car varform))
ad-advised-functions
(, (car (cdr varform))))
@@ -1959,22 +1959,22 @@
(` (copy-tree (get (, function) 'ad-advice-info))))
(defmacro ad-is-advised (function)
- ;;"Returns non-nil if FUNCTION has any advice info associated with it.
- ;;This does not mean that the advice is also active."
+ "Return non-nil if FUNCTION has any advice info associated with it.
+This does not mean that the advice is also active."
(list 'ad-get-advice-info function))
(defun ad-initialize-advice-info (function)
- ;;"Initializes the advice info for FUNCTION.
- ;;Assumes that FUNCTION has not yet been advised."
+ "Initializes the advice info for FUNCTION.
+Assumes that FUNCTION has not yet been advised."
(ad-pushnew-advised-function function)
(ad-set-advice-info function (list (cons 'active nil))))
(defmacro ad-get-advice-info-field (function field)
- ;;"Retrieves the value of the advice info FIELD of FUNCTION."
+ "Retrieves the value of the advice info FIELD of FUNCTION."
(` (cdr (assq (, field) (ad-get-advice-info (, function))))))
(defun ad-set-advice-info-field (function field value)
- ;;"Destructively modifies VALUE of the advice info FIELD of FUNCTION."
+ "Destructively modifies VALUE of the advice info FIELD of FUNCTION."
(and (ad-is-advised function)
(cond ((assq field (ad-get-advice-info function))
;; A field with that name is already present:
@@ -1985,7 +1985,7 @@
;; Don't make this a macro so we can use it as a predicate:
(defun ad-is-active (function)
- ;;"non-nil if FUNCTION is advised and activated."
+ "Return non-nil if FUNCTION is advised and activated."
(ad-get-advice-info-field function 'active))
@@ -2029,27 +2029,27 @@
(defvar ad-advice-classes '(before around after activation deactivation))
(defun ad-has-enabled-advice (function class)
- ;;"True if at least one of FUNCTION's advices in CLASS is enabled."
+ "True if at least one of FUNCTION's advices in CLASS is enabled."
(dolist (advice (ad-get-advice-info-field function class))
(if (ad-advice-enabled advice) (return t))))
(defun ad-has-redefining-advice (function)
- ;;"True if FUNCTION's advice info defines at least 1 redefining advice.
- ;;Redefining advices affect the construction of an advised definition."
+ "True if FUNCTION's advice info defines at least 1 redefining advice.
+Redefining advices affect the construction of an advised definition."
(and (ad-is-advised function)
(or (ad-has-enabled-advice function 'before)
(ad-has-enabled-advice function 'around)
(ad-has-enabled-advice function 'after))))
(defun ad-has-any-advice (function)
- ;;"True if the advice info of FUNCTION defines at least one advice."
+ "True if the advice info of FUNCTION defines at least one advice."
(and (ad-is-advised function)
(dolist (class ad-advice-classes nil)
(if (ad-get-advice-info-field function class)
(return t)))))
(defun ad-get-enabled-advices (function class)
- ;;"Returns the list of enabled advices of FUNCTION in CLASS."
+ "Returns the list of enabled advices of FUNCTION in CLASS."
(let (enabled-advices)
(dolist (advice (ad-get-advice-info-field function class))
(if (ad-advice-enabled advice)
@@ -2101,7 +2101,7 @@
(,@ body))))
(defun ad-safe-fset (symbol definition)
- ;; A safe `fset' which will never call `ad-activate' recursively.
+ "A safe `fset' which will never call `ad-activate' recursively."
(ad-with-auto-activation-disabled
(ad-real-fset symbol definition)))
@@ -2116,7 +2116,7 @@
;; we need to use `ad-real-orig-definition'.
(defun ad-make-origname (function)
- ;;"Makes name to be used to call the original FUNCTION."
+ "Make name to be used to call the original FUNCTION."
(intern (format "ad-Orig-%s" function)))
(defmacro ad-get-orig-definition (function)
@@ -2136,11 +2136,11 @@
;; ===============================
(defun ad-read-advised-function (&optional prompt predicate default)
- ;;"Reads name of advised function with completion from the minibuffer.
- ;;An optional PROMPT will be used to prompt for the function. PREDICATE
- ;;plays the same role as for `try-completion' (which see). DEFAULT will
- ;;be returned on empty input (defaults to the first advised function for
- ;;which PREDICATE returns non-nil)."
+ "Read name of advised function with completion from the minibuffer.
+An optional PROMPT will be used to prompt for the function. PREDICATE
+plays the same role as for `try-completion' (which see). DEFAULT will
+be returned on empty input (defaults to the first advised function for
+which PREDICATE returns non-nil)."
(if (null ad-advised-functions)
(error "ad-read-advised-function: There are no advised functions"))
(setq default
@@ -2175,10 +2175,10 @@
ad-advice-classes))
(defun ad-read-advice-class (function &optional prompt default)
- ;;"Reads a legal advice class with completion from the minibuffer.
- ;;An optional PROMPT will be used to prompt for the class. DEFAULT will
- ;;be returned on empty input (defaults to the first non-empty advice
- ;;class of FUNCTION)."
+ "Read a legal advice class with completion from the minibuffer.
+An optional PROMPT will be used to prompt for the class. DEFAULT will
+be returned on empty input (defaults to the first non-empty advice
+class of FUNCTION)."
(setq default
(or default
(dolist (class ad-advice-classes)
@@ -2193,8 +2193,8 @@
(intern class))))
(defun ad-read-advice-name (function class &optional prompt)
- ;;"Reads name of existing advice of CLASS for FUNCTION with completion.
- ;;An optional PROMPT is used to prompt for the name."
+ "Reads name of existing advice of CLASS for FUNCTION with completion.
+An optional PROMPT is used to prompt for the name."
(let* ((name-completion-table
(mapcar (function (lambda (advice)
(list (symbol-name (ad-advice-name advice)))))
@@ -2211,9 +2211,9 @@
(intern name))))
(defun ad-read-advice-specification (&optional prompt)
- ;;"Reads a complete function/class/name specification from minibuffer.
- ;;The list of read symbols will be returned. The optional PROMPT will
- ;;be used to prompt for the function."
+ "Reads a complete function/class/name specification from minibuffer.
+The list of read symbols will be returned. The optional PROMPT will
+be used to prompt for the function."
(let* ((function (ad-read-advised-function prompt))
(class (ad-read-advice-class function))
(name (ad-read-advice-name function class)))
@@ -2223,7 +2223,7 @@
(defvar ad-last-regexp "")
(defun ad-read-regexp (&optional prompt)
- ;;"Reads a regular expression from the minibuffer."
+ "Read a regular expression from the minibuffer."
(let ((regexp (read-from-minibuffer
(concat (or prompt "Regular expression: ")
(if (equal ad-last-regexp "") ""
@@ -2236,11 +2236,11 @@
;; ===========================================================
(defmacro ad-find-advice (function class name)
- ;;"Finds the first advice of FUNCTION in CLASS with NAME."
+ "Find the first advice of FUNCTION in CLASS with NAME."
(` (assq (, name) (ad-get-advice-info-field (, function) (, class)))))
(defun ad-advice-position (function class name)
- ;;"Returns position of first advice of FUNCTION in CLASS with NAME."
+ "Return position of first advice of FUNCTION in CLASS with NAME."
(let* ((found-advice (ad-find-advice function class name))
(advices (ad-get-advice-info-field function class)))
(if found-advice
@@ -2429,19 +2429,19 @@
(ad-safe-fset 'byte-code-function-p 'compiled-function-p))
(defmacro ad-compiled-p (definition)
- ;;"non-nil if DEFINITION is a compiled byte-code object."
+ "Return non-nil if DEFINITION is a compiled byte-code object."
(` (or (byte-code-function-p (, definition))
(and (ad-macro-p (, definition))
(byte-code-function-p (ad-lambdafy (, definition)))))))
(defmacro ad-compiled-code (compiled-definition)
- ;;"Returns the byte-code object of a COMPILED-DEFINITION."
+ "Return the byte-code object of a COMPILED-DEFINITION."
(` (if (ad-macro-p (, compiled-definition))
(ad-lambdafy (, compiled-definition))
(, compiled-definition))))
(defun ad-lambda-expression (definition)
- ;;"Returns the lambda expression of a function/macro/advice DEFINITION."
+ "Return the lambda expression of a function/macro/advice DEFINITION."
(cond ((ad-lambda-p definition)
definition)
((ad-macro-p definition)
@@ -2451,9 +2451,9 @@
(t nil)))
(defun ad-arglist (definition &optional name)
- ;;"Returns the argument list of DEFINITION.
- ;;If DEFINITION could be from a subr then its NAME should be
- ;;supplied to make subr arglist lookup more efficient."
+ "Return the argument list of DEFINITION.
+If DEFINITION could be from a subr then its NAME should be
+supplied to make subr arglist lookup more efficient."
(cond ((ad-compiled-p definition)
;; XEmacs fix:
(if (featurep 'xemacs)
@@ -2482,10 +2482,10 @@
(` (car (get (, subr) 'ad-subr-arglist))))
(defun ad-subr-arglist (subr-name)
- ;;"Retrieve arglist of the subr with SUBR-NAME.
- ;;Either use the one stored under the `ad-subr-arglist' property,
- ;;or try to retrieve it from the docstring and cache it under
- ;;that property, or otherwise use `(&rest ad-subr-args)'."
+ "Retrieve arglist of the subr with SUBR-NAME.
+Either use the one stored under the `ad-subr-arglist' property,
+or try to retrieve it from the docstring and cache it under
+that property, or otherwise use `(&rest ad-subr-args)'."
(cond ((ad-subr-args-defined-p subr-name)
(ad-get-subr-args subr-name))
;; says jwz: Should use this for Lemacs 19.8 and above:
@@ -2524,7 +2524,7 @@
(t '(&rest ad-subr-args)))))))
(defun ad-docstring (definition)
- ;;"Returns the unexpanded docstring of DEFINITION."
+ "Return the unexpanded docstring of DEFINITION."
(let ((docstring
(if (ad-compiled-p definition)
(ad-real-documentation definition t)
@@ -2534,7 +2534,7 @@
docstring)))
(defun ad-interactive-form (definition)
- ;;"Returns the interactive form of DEFINITION."
+ "Return the interactive form of DEFINITION."
(cond ((ad-compiled-p definition)
(and (commandp definition)
;; XEmacs: we have an accessor function so don't use aref.
@@ -2546,7 +2546,7 @@
(commandp (ad-lambda-expression definition)))))
(defun ad-body-forms (definition)
- ;;"Returns the list of body forms of DEFINITION."
+ "Return the list of body forms of DEFINITION."
(cond ((ad-compiled-p definition)
nil)
((consp definition)
@@ -2559,15 +2559,15 @@
(defvar ad-advised-definition-docstring-regexp "^\\$ad-doc: \\(.+\\)\\$$")
(defun ad-make-advised-definition-docstring (function)
- ;; Makes an identifying docstring for the advised definition of FUNCTION.
- ;; Put function name into the documentation string so we can infer
- ;; the name of the advised function from the docstring. This is needed
- ;; to generate a proper advised docstring even if we are just given a
- ;; definition (also see the defadvice for `documentation'):
+ "Make an identifying docstring for the advised definition of FUNCTION.
+Put function name into the documentation string so we can infer
+the name of the advised function from the docstring. This is needed
+to generate a proper advised docstring even if we are just given a
+definition (also see the defadvice for `documentation')."
(format "$ad-doc: %s$" (prin1-to-string function)))
(defun ad-advised-definition-p (definition)
- ;;"non-nil if DEFINITION was generated from advice information."
+ "Return non-nil if DEFINITION was generated from advice information."
(if (or (ad-lambda-p definition)
(ad-macro-p definition)
(ad-compiled-p definition))
@@ -2577,7 +2577,7 @@
ad-advised-definition-docstring-regexp docstring)))))
(defun ad-definition-type (definition)
- ;;"Returns symbol that describes the type of DEFINITION."
+ "Return symbol that describes the type of DEFINITION."
(if (ad-macro-p definition)
'macro
(if (ad-subr-p definition)
@@ -2591,8 +2591,8 @@
'advice)))))
(defun ad-has-proper-definition (function)
- ;;"True if FUNCTION is a symbol with a proper definition.
- ;;For that it has to be fbound with a non-autoload definition."
+ "True if FUNCTION is a symbol with a proper definition.
+For that it has to be fbound with a non-autoload definition."
(and (symbolp function)
(fboundp function)
(not (eq (car-safe (symbol-function function)) 'autoload))))
@@ -2600,7 +2600,7 @@
;; The following two are necessary for the sake of packages such as
;; ange-ftp which redefine functions via fcell indirection:
(defun ad-real-definition (function)
- ;;"Finds FUNCTION's definition at the end of function cell indirection."
+ "Find FUNCTION's definition at the end of function cell indirection."
(if (ad-has-proper-definition function)
(let ((definition (symbol-function function)))
(if (symbolp definition)
@@ -2608,19 +2608,19 @@
definition))))
(defun ad-real-orig-definition (function)
- ;;"Finds FUNCTION's real original definition starting from its `origname'."
+ "Find FUNCTION's real original definition starting from its `origname'."
(if (ad-is-advised function)
(ad-real-definition (ad-get-advice-info-field function 'origname))))
(defun ad-is-compilable (function)
- ;;"True if FUNCTION has an interpreted definition that can be compiled."
+ "True if FUNCTION has an interpreted definition that can be compiled."
(and (ad-has-proper-definition function)
(or (ad-lambda-p (symbol-function function))
(ad-macro-p (symbol-function function)))
(not (ad-compiled-p (symbol-function function)))))
(defun ad-compile-function (function)
- "Byte-compiles FUNCTION (or macro) if it is not yet compiled."
+ "Byte-compile FUNCTION (or macro) if it is not yet compiled."
(interactive "aByte-compile function: ")
(if (ad-is-compilable function)
;; Need to turn off auto-activation
@@ -2667,10 +2667,10 @@
;; =============================
(defun ad-parse-arglist (arglist)
- ;;"Parses ARGLIST into its required, optional and rest parameters.
- ;;A three-element list is returned, where the 1st element is the list of
- ;;required arguments, the 2nd is the list of optional arguments, and the 3rd
- ;;is the name of an optional rest parameter (or nil)."
+ "Parse ARGLIST into its required, optional and rest parameters.
+A three-element list is returned, where the 1st element is the list of
+required arguments, the 2nd is the list of optional arguments, and the 3rd
+is the name of an optional rest parameter (or nil)."
(let* (required optional rest)
(setq rest (car (cdr (memq '&rest arglist))))
(if rest (setq arglist (reverse (cdr (memq '&rest (reverse arglist))))))
@@ -2681,12 +2681,12 @@
(list required optional rest)))
(defun ad-retrieve-args-form (arglist)
- ;;"Generates a form which evaluates into names/values/types of ARGLIST.
- ;;When the form gets evaluated within a function with that argument list
- ;;it will result in a list with one entry for each argument, where the
- ;;first element of each entry is the name of the argument, the second
- ;;element is its actual current value, and the third element is either
- ;;`required', `optional' or `rest' depending on the type of the argument."
+ "Generate a form which evaluates into names/values/types of ARGLIST.
+When the form gets evaluated within a function with that argument list
+it will result in a list with one entry for each argument, where the
+first element of each entry is the name of the argument, the second
+element is its actual current value, and the third element is either
+`required', `optional' or `rest' depending on the type of the argument."
(let* ((parsed-arglist (ad-parse-arglist arglist))
(rest (nth 2 parsed-arglist)))
(` (list
@@ -2717,9 +2717,9 @@
(t (list 'nth position list))))
(defun ad-access-argument (arglist index)
- ;;"Tells how to access ARGLIST's actual argument at position INDEX.
- ;;For a required/optional arg it simply returns it, if a rest argument has
- ;;to be accessed, it returns a list with the index and name."
+ "Tells how to access ARGLIST's actual argument at position INDEX.
+For a required/optional arg it simply returns it, if a rest argument has
+to be accessed, it returns a list with the index and name."
(let* ((parsed-arglist (ad-parse-arglist arglist))
(reqopt-args (append (nth 0 parsed-arglist)
(nth 1 parsed-arglist)))
@@ -2730,7 +2730,7 @@
(list (- index (length reqopt-args)) rest-arg)))))
(defun ad-get-argument (arglist index)
- ;;"Returns form to access ARGLIST's actual argument at position INDEX."
+ "Returns form to access ARGLIST's actual argument at position INDEX."
(let ((argument-access (ad-access-argument arglist index)))
(cond ((consp argument-access)
(ad-element-access
@@ -2738,7 +2738,7 @@
(argument-access))))
(defun ad-set-argument (arglist index value-form)
- ;;"Returns form to set ARGLIST's actual arg at INDEX to VALUE-FORM."
+ "Returns form to set ARGLIST's actual arg at INDEX to VALUE-FORM."
(let ((argument-access (ad-access-argument arglist index)))
(cond ((consp argument-access)
;; should this check whether there actually is something to set?
@@ -2751,7 +2751,7 @@
index arglist)))))
(defun ad-get-arguments (arglist index)
- ;;"Returns form to access all actual arguments starting at position INDEX."
+ "Returns form to access all actual arguments starting at position INDEX."
(let* ((parsed-arglist (ad-parse-arglist arglist))
(reqopt-args (append (nth 0 parsed-arglist)
(nth 1 parsed-arglist)))
@@ -2767,8 +2767,8 @@
args-form))
(defun ad-set-arguments (arglist index values-form)
- ;;"Makes form to assign elements of VALUES-FORM as actual ARGLIST args.
- ;;The assignment starts at position INDEX."
+ "Makes form to assign elements of VALUES-FORM as actual ARGLIST args.
+The assignment starts at position INDEX."
(let ((values-index 0)
argument-access set-forms)
(while (setq argument-access (ad-access-argument arglist index))
@@ -2805,7 +2805,7 @@
(, 'ad-vAlUeS)))))))
(defun ad-insert-argument-access-forms (definition arglist)
- ;;"Expands arg-access text macros in DEFINITION according to ARGLIST."
+ "Expand arg-access text macros in DEFINITION according to ARGLIST."
(macrolet
((subtree-test (form)
`(funcall #'(lambda (form)
@@ -2892,7 +2892,7 @@
source-reqopt-args)))))))))
(defun ad-make-mapped-call (source-arglist target-arglist target-function)
- ;;"Makes form to call TARGET-FUNCTION with args from SOURCE-ARGLIST."
+ "Make form to call TARGET-FUNCTION with args from SOURCE-ARGLIST."
(let* ((mapped-form (ad-map-arglists source-arglist target-arglist)))
(if (eq (car mapped-form) 'funcall)
(cons target-function (cdr (cdr mapped-form)))
@@ -2925,13 +2925,13 @@
(or advice-docstring ""))))))
(defun ad-make-advised-docstring (function &optional style)
- ;;"Constructs a documentation string for the advised FUNCTION.
- ;;It concatenates the original documentation with the documentation
- ;;strings of the individual pieces of advice which will be formatted
- ;;according to STYLE. STYLE can be `plain' or `freeze', everything else
- ;;will be interpreted as `default'. The order of the advice documentation
- ;;strings corresponds to before/around/after and the individual ordering
- ;;in any of these classes."
+ "Construct a documentation string for the advised FUNCTION.
+It concatenates the original documentation with the documentation
+strings of the individual pieces of advice which will be formatted
+according to STYLE. STYLE can be `plain' or `freeze', everything else
+will be interpreted as `default'. The order of the advice documentation
+strings corresponds to before/around/after and the individual ordering
+in any of these classes."
(let* ((origdef (ad-real-orig-definition function))
(origtype (symbol-name (ad-definition-type origdef)))
(origdoc
@@ -2961,7 +2961,7 @@
;; ========================================================
(defun ad-advised-arglist (function)
- ;;"Finds first defined arglist in FUNCTION's redefining advices."
+ "Find first defined arglist in FUNCTION's redefining advices."
(dolist (advice (append (ad-get-enabled-advices function 'before)
(ad-get-enabled-advices function 'around)
(ad-get-enabled-advices function 'after)))
@@ -2971,7 +2971,7 @@
(return arglist)))))
(defun ad-advised-interactive-form (function)
- ;;"Finds first interactive form in FUNCTION's redefining advices."
+ "Find first interactive form in FUNCTION's redefining advices."
(dolist (advice (append (ad-get-enabled-advices function 'before)
(ad-get-enabled-advices function 'around)
(ad-get-enabled-advices function 'after)))
@@ -2985,7 +2985,7 @@
;; ============================
(defun ad-make-advised-definition (function)
- ;;"Generates an advised definition of FUNCTION from its advice info."
+ "Generate an advised definition of FUNCTION from its advice info."
(if (and (ad-is-advised function)
(ad-has-redefining-advice function))
(let* ((origdef (ad-real-orig-definition function))
@@ -3129,7 +3129,7 @@
;; This is needed for activation/deactivation hooks:
(defun ad-make-hook-form (function hook-name)
- ;;"Makes hook-form from FUNCTION's advice bodies in class HOOK-NAME."
+ "Make hook-form from FUNCTION's advice bodies in class HOOK-NAME."
(let ((hook-forms
(mapcar (function (lambda (advice)
(ad-body-forms (ad-advice-definition advice))))
@@ -3217,7 +3217,7 @@
(ad-set-advice-info-field function 'cache nil))
(defun ad-make-cache-id (function)
- ;;"Generates an identifying image of the current advices of FUNCTION."
+ "Generate an identifying image of the current advices of FUNCTION."
(let ((original-definition (ad-real-orig-definition function))
(cached-definition (ad-get-cache-definition function)))
(list (mapcar (function (lambda (advice) (ad-advice-name advice)))
@@ -3236,7 +3236,7 @@
(ad-interactive-form cached-definition))))))
(defun ad-get-cache-class-id (function class)
- ;;"Returns the part of FUNCTION's cache id that identifies CLASS."
+ "Return the part of FUNCTION's cache id that identifies CLASS."
(let ((cache-id (ad-get-cache-id function)))
(if (eq class 'before)
(car cache-id)
@@ -3286,7 +3286,7 @@
code))
(defun ad-verify-cache-id (function)
- ;;"True if FUNCTION's cache-id is compatible with its current advices."
+ "True if FUNCTION's cache-id is compatible with its current advices."
(eq (ad-cache-id-verification-code function) 'verified))
@@ -3314,7 +3314,7 @@
;; advised definition will be generated.
(defun ad-preactivate-advice (function advice class position)
- ;;"Preactivates FUNCTION and returns the constructed cache."
+ "Preactivate FUNCTION and returns the constructed cache."
(let* ((function-defined-p (fboundp function))
(old-definition
(if function-defined-p
@@ -3426,11 +3426,11 @@
;; ======================================
(defun ad-should-compile (function compile)
- ;;"Returns non-nil if the advised FUNCTION should be compiled.
- ;;If COMPILE is non-nil and not a negative number then it returns t.
- ;;If COMPILE is a negative number then it returns nil.
- ;;If COMPILE is nil then the result depends on the value of
- ;;`ad-default-compilation-action' (which see)."
+ "Return non-nil if the advised FUNCTION should be compiled.
+If COMPILE is non-nil and not a negative number then it returns t.
+If COMPILE is a negative number then it returns nil.
+If COMPILE is nil then the result depends on the value of
+`ad-default-compilation-action' (which see)."
(if (integerp compile)
(>= compile 0)
(if compile
@@ -3446,9 +3446,9 @@
(t (featurep 'byte-compile))))))
(defun ad-activate-advised-definition (function compile)
- ;;"Redefines FUNCTION with its advised definition from cache or scratch.
- ;;The resulting FUNCTION will be compiled if `ad-should-compile' returns t.
- ;;The current definition and its cache-id will be put into the cache."
+ "Redefine FUNCTION with its advised definition from cache or scratch.
+The resulting FUNCTION will be compiled if `ad-should-compile' returns t.
+The current definition and its cache-id will be put into the cache."
(let ((verified-cached-definition
(if (ad-verify-cache-id function)
(ad-get-cache-definition function))))
--
‘Iodine deficiency was endemic in parts of the UK until, through what has been
described as “an unplanned and accidental public health triumph”, iodine was
added to cattle feed to improve milk production in the 1930s.’
(EN Pearce, Lancet, June 2011)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
commit/xemacs-base: 2 new changesets
12 years, 7 months
Bitbucket
2 new commits in xemacs-base:
https://bitbucket.org/xemacs/xemacs-base/changeset/51d722692ee0/
changeset: 51d722692ee0
user: kehoea
date: 2012-05-11 18:41:54
summary: Uncomment docstrings, advice.el.
2012-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
* advice.el (ad-pushnew-advised-function):
* advice.el (ad-pop-advised-function):
* advice.el (ad-do-advised-functions):
* advice.el (ad-is-advised):
* advice.el (ad-initialize-advice-info):
* advice.el (ad-get-advice-info-field):
* advice.el (ad-set-advice-info-field):
* advice.el (ad-is-active):
* advice.el (ad-has-enabled-advice):
* advice.el (ad-has-redefining-advice):
* advice.el (ad-has-any-advice):
* advice.el (ad-get-enabled-advices):
* advice.el (ad-safe-fset):
* advice.el (ad-make-origname):
* advice.el (ad-read-advised-function):
* advice.el (ad-read-advice-class):
* advice.el (ad-read-advice-name):
* advice.el (ad-read-advice-specification):
* advice.el (ad-read-regexp):
* advice.el (ad-find-advice):
* advice.el (ad-advice-position):
* advice.el (ad-compiled-p):
* advice.el (ad-compiled-code):
* advice.el (ad-lambda-expression):
* advice.el (ad-arglist):
* advice.el (ad-subr-arglist):
* advice.el (ad-docstring):
* advice.el (ad-interactive-form):
* advice.el (ad-body-forms):
* advice.el (ad-make-advised-definition-docstring):
* advice.el (ad-advised-definition-p):
* advice.el (ad-definition-type):
* advice.el (ad-has-proper-definition):
* advice.el (ad-real-definition):
* advice.el (ad-real-orig-definition):
* advice.el (ad-is-compilable):
* advice.el (ad-compile-function):
* advice.el (ad-parse-arglist):
* advice.el (ad-retrieve-args-form):
* advice.el (ad-access-argument):
* advice.el (ad-get-argument):
* advice.el (ad-set-argument):
* advice.el (ad-get-arguments):
* advice.el (ad-set-arguments):
* advice.el (ad-insert-argument-access-forms):
* advice.el (ad-make-mapped-call):
* advice.el (ad-make-advised-docstring):
* advice.el (ad-advised-arglist):
* advice.el (ad-advised-interactive-form):
* advice.el (ad-make-advised-definition):
* advice.el (ad-make-hook-form):
* advice.el (ad-make-cache-id):
* advice.el (ad-get-cache-class-id):
* advice.el (ad-verify-cache-id):
* advice.el (ad-preactivate-advice):
* advice.el (ad-should-compile):
* advice.el (ad-activate-advised-definition):
Uncomment the docstrings for these functions, they take up negligible
space these days.
affected #: 2 files
diff -r d56f8e5d14021584dbef7f97c5985c36f19980cf -r 51d722692ee03cc29c3a708e66e4b46dc164a117 ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,65 @@
+2012-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * advice.el (ad-pushnew-advised-function):
+ * advice.el (ad-pop-advised-function):
+ * advice.el (ad-do-advised-functions):
+ * advice.el (ad-is-advised):
+ * advice.el (ad-initialize-advice-info):
+ * advice.el (ad-get-advice-info-field):
+ * advice.el (ad-set-advice-info-field):
+ * advice.el (ad-is-active):
+ * advice.el (ad-has-enabled-advice):
+ * advice.el (ad-has-redefining-advice):
+ * advice.el (ad-has-any-advice):
+ * advice.el (ad-get-enabled-advices):
+ * advice.el (ad-safe-fset):
+ * advice.el (ad-make-origname):
+ * advice.el (ad-read-advised-function):
+ * advice.el (ad-read-advice-class):
+ * advice.el (ad-read-advice-name):
+ * advice.el (ad-read-advice-specification):
+ * advice.el (ad-read-regexp):
+ * advice.el (ad-find-advice):
+ * advice.el (ad-advice-position):
+ * advice.el (ad-compiled-p):
+ * advice.el (ad-compiled-code):
+ * advice.el (ad-lambda-expression):
+ * advice.el (ad-arglist):
+ * advice.el (ad-subr-arglist):
+ * advice.el (ad-docstring):
+ * advice.el (ad-interactive-form):
+ * advice.el (ad-body-forms):
+ * advice.el (ad-make-advised-definition-docstring):
+ * advice.el (ad-advised-definition-p):
+ * advice.el (ad-definition-type):
+ * advice.el (ad-has-proper-definition):
+ * advice.el (ad-real-definition):
+ * advice.el (ad-real-orig-definition):
+ * advice.el (ad-is-compilable):
+ * advice.el (ad-compile-function):
+ * advice.el (ad-parse-arglist):
+ * advice.el (ad-retrieve-args-form):
+ * advice.el (ad-access-argument):
+ * advice.el (ad-get-argument):
+ * advice.el (ad-set-argument):
+ * advice.el (ad-get-arguments):
+ * advice.el (ad-set-arguments):
+ * advice.el (ad-insert-argument-access-forms):
+ * advice.el (ad-make-mapped-call):
+ * advice.el (ad-make-advised-docstring):
+ * advice.el (ad-advised-arglist):
+ * advice.el (ad-advised-interactive-form):
+ * advice.el (ad-make-advised-definition):
+ * advice.el (ad-make-hook-form):
+ * advice.el (ad-make-cache-id):
+ * advice.el (ad-get-cache-class-id):
+ * advice.el (ad-verify-cache-id):
+ * advice.el (ad-preactivate-advice):
+ * advice.el (ad-should-compile):
+ * advice.el (ad-activate-advised-definition):
+ Uncomment the docstrings for these functions, they take up negligible
+ space these days.
+
2012-01-10 Norbert Koch <viteno(a)xemacs.org>
* Makefile (VERSION): XEmacs package 2.31 released.
diff -r d56f8e5d14021584dbef7f97c5985c36f19980cf -r 51d722692ee03cc29c3a708e66e4b46dc164a117 advice.el
--- a/advice.el
+++ b/advice.el
@@ -1922,24 +1922,24 @@
(defvar ad-advised-functions nil)
(defmacro ad-pushnew-advised-function (function)
- ;;"Add FUNCTION to `ad-advised-functions' unless its already there."
+ "Add FUNCTION to `ad-advised-functions' unless its already there."
(` (if (not (assoc (symbol-name (, function)) ad-advised-functions))
(setq ad-advised-functions
(cons (list (symbol-name (, function)))
ad-advised-functions)))))
(defmacro ad-pop-advised-function (function)
- ;;"Remove FUNCTION from `ad-advised-functions'."
+ "Remove FUNCTION from `ad-advised-functions'."
(` (setq ad-advised-functions
(delq (assoc (symbol-name (, function)) ad-advised-functions)
ad-advised-functions))))
(defmacro ad-do-advised-functions (varform &rest body)
- ;;"`dolist'-style iterator that maps over `ad-advised-functions'.
- ;; (ad-do-advised-functions (VAR [RESULT-FORM])
- ;; BODY-FORM...)
- ;;Also see `dolist'. On each iteration VAR will be bound to the
- ;;name of an advised function (a symbol)."
+ "`dolist'-style iterator that maps over `ad-advised-functions'.
+ (ad-do-advised-functions (VAR [RESULT-FORM])
+ BODY-FORM...)
+Also see `dolist'. On each iteration VAR will be bound to the
+name of an advised function (a symbol)."
(` (dolist ((, (car varform))
ad-advised-functions
(, (car (cdr varform))))
@@ -1959,22 +1959,22 @@
(` (copy-tree (get (, function) 'ad-advice-info))))
(defmacro ad-is-advised (function)
- ;;"Returns non-nil if FUNCTION has any advice info associated with it.
- ;;This does not mean that the advice is also active."
+ "Return non-nil if FUNCTION has any advice info associated with it.
+This does not mean that the advice is also active."
(list 'ad-get-advice-info function))
(defun ad-initialize-advice-info (function)
- ;;"Initializes the advice info for FUNCTION.
- ;;Assumes that FUNCTION has not yet been advised."
+ "Initializes the advice info for FUNCTION.
+Assumes that FUNCTION has not yet been advised."
(ad-pushnew-advised-function function)
(ad-set-advice-info function (list (cons 'active nil))))
(defmacro ad-get-advice-info-field (function field)
- ;;"Retrieves the value of the advice info FIELD of FUNCTION."
+ "Retrieves the value of the advice info FIELD of FUNCTION."
(` (cdr (assq (, field) (ad-get-advice-info (, function))))))
(defun ad-set-advice-info-field (function field value)
- ;;"Destructively modifies VALUE of the advice info FIELD of FUNCTION."
+ "Destructively modifies VALUE of the advice info FIELD of FUNCTION."
(and (ad-is-advised function)
(cond ((assq field (ad-get-advice-info function))
;; A field with that name is already present:
@@ -1985,7 +1985,7 @@
;; Don't make this a macro so we can use it as a predicate:
(defun ad-is-active (function)
- ;;"non-nil if FUNCTION is advised and activated."
+ "Return non-nil if FUNCTION is advised and activated."
(ad-get-advice-info-field function 'active))
@@ -2029,27 +2029,27 @@
(defvar ad-advice-classes '(before around after activation deactivation))
(defun ad-has-enabled-advice (function class)
- ;;"True if at least one of FUNCTION's advices in CLASS is enabled."
+ "True if at least one of FUNCTION's advices in CLASS is enabled."
(dolist (advice (ad-get-advice-info-field function class))
(if (ad-advice-enabled advice) (return t))))
(defun ad-has-redefining-advice (function)
- ;;"True if FUNCTION's advice info defines at least 1 redefining advice.
- ;;Redefining advices affect the construction of an advised definition."
+ "True if FUNCTION's advice info defines at least 1 redefining advice.
+Redefining advices affect the construction of an advised definition."
(and (ad-is-advised function)
(or (ad-has-enabled-advice function 'before)
(ad-has-enabled-advice function 'around)
(ad-has-enabled-advice function 'after))))
(defun ad-has-any-advice (function)
- ;;"True if the advice info of FUNCTION defines at least one advice."
+ "True if the advice info of FUNCTION defines at least one advice."
(and (ad-is-advised function)
(dolist (class ad-advice-classes nil)
(if (ad-get-advice-info-field function class)
(return t)))))
(defun ad-get-enabled-advices (function class)
- ;;"Returns the list of enabled advices of FUNCTION in CLASS."
+ "Returns the list of enabled advices of FUNCTION in CLASS."
(let (enabled-advices)
(dolist (advice (ad-get-advice-info-field function class))
(if (ad-advice-enabled advice)
@@ -2101,7 +2101,7 @@
(,@ body))))
(defun ad-safe-fset (symbol definition)
- ;; A safe `fset' which will never call `ad-activate' recursively.
+ "A safe `fset' which will never call `ad-activate' recursively."
(ad-with-auto-activation-disabled
(ad-real-fset symbol definition)))
@@ -2116,7 +2116,7 @@
;; we need to use `ad-real-orig-definition'.
(defun ad-make-origname (function)
- ;;"Makes name to be used to call the original FUNCTION."
+ "Make name to be used to call the original FUNCTION."
(intern (format "ad-Orig-%s" function)))
(defmacro ad-get-orig-definition (function)
@@ -2136,11 +2136,11 @@
;; ===============================
(defun ad-read-advised-function (&optional prompt predicate default)
- ;;"Reads name of advised function with completion from the minibuffer.
- ;;An optional PROMPT will be used to prompt for the function. PREDICATE
- ;;plays the same role as for `try-completion' (which see). DEFAULT will
- ;;be returned on empty input (defaults to the first advised function for
- ;;which PREDICATE returns non-nil)."
+ "Read name of advised function with completion from the minibuffer.
+An optional PROMPT will be used to prompt for the function. PREDICATE
+plays the same role as for `try-completion' (which see). DEFAULT will
+be returned on empty input (defaults to the first advised function for
+which PREDICATE returns non-nil)."
(if (null ad-advised-functions)
(error "ad-read-advised-function: There are no advised functions"))
(setq default
@@ -2175,10 +2175,10 @@
ad-advice-classes))
(defun ad-read-advice-class (function &optional prompt default)
- ;;"Reads a legal advice class with completion from the minibuffer.
- ;;An optional PROMPT will be used to prompt for the class. DEFAULT will
- ;;be returned on empty input (defaults to the first non-empty advice
- ;;class of FUNCTION)."
+ "Read a legal advice class with completion from the minibuffer.
+An optional PROMPT will be used to prompt for the class. DEFAULT will
+be returned on empty input (defaults to the first non-empty advice
+class of FUNCTION)."
(setq default
(or default
(dolist (class ad-advice-classes)
@@ -2193,8 +2193,8 @@
(intern class))))
(defun ad-read-advice-name (function class &optional prompt)
- ;;"Reads name of existing advice of CLASS for FUNCTION with completion.
- ;;An optional PROMPT is used to prompt for the name."
+ "Reads name of existing advice of CLASS for FUNCTION with completion.
+An optional PROMPT is used to prompt for the name."
(let* ((name-completion-table
(mapcar (function (lambda (advice)
(list (symbol-name (ad-advice-name advice)))))
@@ -2211,9 +2211,9 @@
(intern name))))
(defun ad-read-advice-specification (&optional prompt)
- ;;"Reads a complete function/class/name specification from minibuffer.
- ;;The list of read symbols will be returned. The optional PROMPT will
- ;;be used to prompt for the function."
+ "Reads a complete function/class/name specification from minibuffer.
+The list of read symbols will be returned. The optional PROMPT will
+be used to prompt for the function."
(let* ((function (ad-read-advised-function prompt))
(class (ad-read-advice-class function))
(name (ad-read-advice-name function class)))
@@ -2223,7 +2223,7 @@
(defvar ad-last-regexp "")
(defun ad-read-regexp (&optional prompt)
- ;;"Reads a regular expression from the minibuffer."
+ "Read a regular expression from the minibuffer."
(let ((regexp (read-from-minibuffer
(concat (or prompt "Regular expression: ")
(if (equal ad-last-regexp "") ""
@@ -2236,11 +2236,11 @@
;; ===========================================================
(defmacro ad-find-advice (function class name)
- ;;"Finds the first advice of FUNCTION in CLASS with NAME."
+ "Find the first advice of FUNCTION in CLASS with NAME."
(` (assq (, name) (ad-get-advice-info-field (, function) (, class)))))
(defun ad-advice-position (function class name)
- ;;"Returns position of first advice of FUNCTION in CLASS with NAME."
+ "Return position of first advice of FUNCTION in CLASS with NAME."
(let* ((found-advice (ad-find-advice function class name))
(advices (ad-get-advice-info-field function class)))
(if found-advice
@@ -2429,19 +2429,19 @@
(ad-safe-fset 'byte-code-function-p 'compiled-function-p))
(defmacro ad-compiled-p (definition)
- ;;"non-nil if DEFINITION is a compiled byte-code object."
+ "Return non-nil if DEFINITION is a compiled byte-code object."
(` (or (byte-code-function-p (, definition))
(and (ad-macro-p (, definition))
(byte-code-function-p (ad-lambdafy (, definition)))))))
(defmacro ad-compiled-code (compiled-definition)
- ;;"Returns the byte-code object of a COMPILED-DEFINITION."
+ "Return the byte-code object of a COMPILED-DEFINITION."
(` (if (ad-macro-p (, compiled-definition))
(ad-lambdafy (, compiled-definition))
(, compiled-definition))))
(defun ad-lambda-expression (definition)
- ;;"Returns the lambda expression of a function/macro/advice DEFINITION."
+ "Return the lambda expression of a function/macro/advice DEFINITION."
(cond ((ad-lambda-p definition)
definition)
((ad-macro-p definition)
@@ -2451,9 +2451,9 @@
(t nil)))
(defun ad-arglist (definition &optional name)
- ;;"Returns the argument list of DEFINITION.
- ;;If DEFINITION could be from a subr then its NAME should be
- ;;supplied to make subr arglist lookup more efficient."
+ "Return the argument list of DEFINITION.
+If DEFINITION could be from a subr then its NAME should be
+supplied to make subr arglist lookup more efficient."
(cond ((ad-compiled-p definition)
;; XEmacs fix:
(if (featurep 'xemacs)
@@ -2482,10 +2482,10 @@
(` (car (get (, subr) 'ad-subr-arglist))))
(defun ad-subr-arglist (subr-name)
- ;;"Retrieve arglist of the subr with SUBR-NAME.
- ;;Either use the one stored under the `ad-subr-arglist' property,
- ;;or try to retrieve it from the docstring and cache it under
- ;;that property, or otherwise use `(&rest ad-subr-args)'."
+ "Retrieve arglist of the subr with SUBR-NAME.
+Either use the one stored under the `ad-subr-arglist' property,
+or try to retrieve it from the docstring and cache it under
+that property, or otherwise use `(&rest ad-subr-args)'."
(cond ((ad-subr-args-defined-p subr-name)
(ad-get-subr-args subr-name))
;; says jwz: Should use this for Lemacs 19.8 and above:
@@ -2524,7 +2524,7 @@
(t '(&rest ad-subr-args)))))))
(defun ad-docstring (definition)
- ;;"Returns the unexpanded docstring of DEFINITION."
+ "Return the unexpanded docstring of DEFINITION."
(let ((docstring
(if (ad-compiled-p definition)
(ad-real-documentation definition t)
@@ -2534,7 +2534,7 @@
docstring)))
(defun ad-interactive-form (definition)
- ;;"Returns the interactive form of DEFINITION."
+ "Return the interactive form of DEFINITION."
(cond ((ad-compiled-p definition)
(and (commandp definition)
;; XEmacs: we have an accessor function so don't use aref.
@@ -2546,7 +2546,7 @@
(commandp (ad-lambda-expression definition)))))
(defun ad-body-forms (definition)
- ;;"Returns the list of body forms of DEFINITION."
+ "Return the list of body forms of DEFINITION."
(cond ((ad-compiled-p definition)
nil)
((consp definition)
@@ -2559,15 +2559,15 @@
(defvar ad-advised-definition-docstring-regexp "^\\$ad-doc: \\(.+\\)\\$$")
(defun ad-make-advised-definition-docstring (function)
- ;; Makes an identifying docstring for the advised definition of FUNCTION.
- ;; Put function name into the documentation string so we can infer
- ;; the name of the advised function from the docstring. This is needed
- ;; to generate a proper advised docstring even if we are just given a
- ;; definition (also see the defadvice for `documentation'):
+ "Make an identifying docstring for the advised definition of FUNCTION.
+Put function name into the documentation string so we can infer
+the name of the advised function from the docstring. This is needed
+to generate a proper advised docstring even if we are just given a
+definition (also see the defadvice for `documentation')."
(format "$ad-doc: %s$" (prin1-to-string function)))
(defun ad-advised-definition-p (definition)
- ;;"non-nil if DEFINITION was generated from advice information."
+ "Return non-nil if DEFINITION was generated from advice information."
(if (or (ad-lambda-p definition)
(ad-macro-p definition)
(ad-compiled-p definition))
@@ -2577,7 +2577,7 @@
ad-advised-definition-docstring-regexp docstring)))))
(defun ad-definition-type (definition)
- ;;"Returns symbol that describes the type of DEFINITION."
+ "Return symbol that describes the type of DEFINITION."
(if (ad-macro-p definition)
'macro
(if (ad-subr-p definition)
@@ -2591,8 +2591,8 @@
'advice)))))
(defun ad-has-proper-definition (function)
- ;;"True if FUNCTION is a symbol with a proper definition.
- ;;For that it has to be fbound with a non-autoload definition."
+ "True if FUNCTION is a symbol with a proper definition.
+For that it has to be fbound with a non-autoload definition."
(and (symbolp function)
(fboundp function)
(not (eq (car-safe (symbol-function function)) 'autoload))))
@@ -2600,7 +2600,7 @@
;; The following two are necessary for the sake of packages such as
;; ange-ftp which redefine functions via fcell indirection:
(defun ad-real-definition (function)
- ;;"Finds FUNCTION's definition at the end of function cell indirection."
+ "Find FUNCTION's definition at the end of function cell indirection."
(if (ad-has-proper-definition function)
(let ((definition (symbol-function function)))
(if (symbolp definition)
@@ -2608,19 +2608,19 @@
definition))))
(defun ad-real-orig-definition (function)
- ;;"Finds FUNCTION's real original definition starting from its `origname'."
+ "Find FUNCTION's real original definition starting from its `origname'."
(if (ad-is-advised function)
(ad-real-definition (ad-get-advice-info-field function 'origname))))
(defun ad-is-compilable (function)
- ;;"True if FUNCTION has an interpreted definition that can be compiled."
+ "True if FUNCTION has an interpreted definition that can be compiled."
(and (ad-has-proper-definition function)
(or (ad-lambda-p (symbol-function function))
(ad-macro-p (symbol-function function)))
(not (ad-compiled-p (symbol-function function)))))
(defun ad-compile-function (function)
- "Byte-compiles FUNCTION (or macro) if it is not yet compiled."
+ "Byte-compile FUNCTION (or macro) if it is not yet compiled."
(interactive "aByte-compile function: ")
(if (ad-is-compilable function)
;; Need to turn off auto-activation
@@ -2667,10 +2667,10 @@
;; =============================
(defun ad-parse-arglist (arglist)
- ;;"Parses ARGLIST into its required, optional and rest parameters.
- ;;A three-element list is returned, where the 1st element is the list of
- ;;required arguments, the 2nd is the list of optional arguments, and the 3rd
- ;;is the name of an optional rest parameter (or nil)."
+ "Parse ARGLIST into its required, optional and rest parameters.
+A three-element list is returned, where the 1st element is the list of
+required arguments, the 2nd is the list of optional arguments, and the 3rd
+is the name of an optional rest parameter (or nil)."
(let* (required optional rest)
(setq rest (car (cdr (memq '&rest arglist))))
(if rest (setq arglist (reverse (cdr (memq '&rest (reverse arglist))))))
@@ -2681,12 +2681,12 @@
(list required optional rest)))
(defun ad-retrieve-args-form (arglist)
- ;;"Generates a form which evaluates into names/values/types of ARGLIST.
- ;;When the form gets evaluated within a function with that argument list
- ;;it will result in a list with one entry for each argument, where the
- ;;first element of each entry is the name of the argument, the second
- ;;element is its actual current value, and the third element is either
- ;;`required', `optional' or `rest' depending on the type of the argument."
+ "Generate a form which evaluates into names/values/types of ARGLIST.
+When the form gets evaluated within a function with that argument list
+it will result in a list with one entry for each argument, where the
+first element of each entry is the name of the argument, the second
+element is its actual current value, and the third element is either
+`required', `optional' or `rest' depending on the type of the argument."
(let* ((parsed-arglist (ad-parse-arglist arglist))
(rest (nth 2 parsed-arglist)))
(` (list
@@ -2717,9 +2717,9 @@
(t (list 'nth position list))))
(defun ad-access-argument (arglist index)
- ;;"Tells how to access ARGLIST's actual argument at position INDEX.
- ;;For a required/optional arg it simply returns it, if a rest argument has
- ;;to be accessed, it returns a list with the index and name."
+ "Tells how to access ARGLIST's actual argument at position INDEX.
+For a required/optional arg it simply returns it, if a rest argument has
+to be accessed, it returns a list with the index and name."
(let* ((parsed-arglist (ad-parse-arglist arglist))
(reqopt-args (append (nth 0 parsed-arglist)
(nth 1 parsed-arglist)))
@@ -2730,7 +2730,7 @@
(list (- index (length reqopt-args)) rest-arg)))))
(defun ad-get-argument (arglist index)
- ;;"Returns form to access ARGLIST's actual argument at position INDEX."
+ "Returns form to access ARGLIST's actual argument at position INDEX."
(let ((argument-access (ad-access-argument arglist index)))
(cond ((consp argument-access)
(ad-element-access
@@ -2738,7 +2738,7 @@
(argument-access))))
(defun ad-set-argument (arglist index value-form)
- ;;"Returns form to set ARGLIST's actual arg at INDEX to VALUE-FORM."
+ "Returns form to set ARGLIST's actual arg at INDEX to VALUE-FORM."
(let ((argument-access (ad-access-argument arglist index)))
(cond ((consp argument-access)
;; should this check whether there actually is something to set?
@@ -2751,7 +2751,7 @@
index arglist)))))
(defun ad-get-arguments (arglist index)
- ;;"Returns form to access all actual arguments starting at position INDEX."
+ "Returns form to access all actual arguments starting at position INDEX."
(let* ((parsed-arglist (ad-parse-arglist arglist))
(reqopt-args (append (nth 0 parsed-arglist)
(nth 1 parsed-arglist)))
@@ -2767,8 +2767,8 @@
args-form))
(defun ad-set-arguments (arglist index values-form)
- ;;"Makes form to assign elements of VALUES-FORM as actual ARGLIST args.
- ;;The assignment starts at position INDEX."
+ "Makes form to assign elements of VALUES-FORM as actual ARGLIST args.
+The assignment starts at position INDEX."
(let ((values-index 0)
argument-access set-forms)
(while (setq argument-access (ad-access-argument arglist index))
@@ -2805,7 +2805,7 @@
(, 'ad-vAlUeS)))))))
(defun ad-insert-argument-access-forms (definition arglist)
- ;;"Expands arg-access text macros in DEFINITION according to ARGLIST."
+ "Expand arg-access text macros in DEFINITION according to ARGLIST."
(macrolet
((subtree-test (form)
`(funcall #'(lambda (form)
@@ -2892,7 +2892,7 @@
source-reqopt-args)))))))))
(defun ad-make-mapped-call (source-arglist target-arglist target-function)
- ;;"Makes form to call TARGET-FUNCTION with args from SOURCE-ARGLIST."
+ "Make form to call TARGET-FUNCTION with args from SOURCE-ARGLIST."
(let* ((mapped-form (ad-map-arglists source-arglist target-arglist)))
(if (eq (car mapped-form) 'funcall)
(cons target-function (cdr (cdr mapped-form)))
@@ -2925,13 +2925,13 @@
(or advice-docstring ""))))))
(defun ad-make-advised-docstring (function &optional style)
- ;;"Constructs a documentation string for the advised FUNCTION.
- ;;It concatenates the original documentation with the documentation
- ;;strings of the individual pieces of advice which will be formatted
- ;;according to STYLE. STYLE can be `plain' or `freeze', everything else
- ;;will be interpreted as `default'. The order of the advice documentation
- ;;strings corresponds to before/around/after and the individual ordering
- ;;in any of these classes."
+ "Construct a documentation string for the advised FUNCTION.
+It concatenates the original documentation with the documentation
+strings of the individual pieces of advice which will be formatted
+according to STYLE. STYLE can be `plain' or `freeze', everything else
+will be interpreted as `default'. The order of the advice documentation
+strings corresponds to before/around/after and the individual ordering
+in any of these classes."
(let* ((origdef (ad-real-orig-definition function))
(origtype (symbol-name (ad-definition-type origdef)))
(origdoc
@@ -2961,7 +2961,7 @@
;; ========================================================
(defun ad-advised-arglist (function)
- ;;"Finds first defined arglist in FUNCTION's redefining advices."
+ "Find first defined arglist in FUNCTION's redefining advices."
(dolist (advice (append (ad-get-enabled-advices function 'before)
(ad-get-enabled-advices function 'around)
(ad-get-enabled-advices function 'after)))
@@ -2971,7 +2971,7 @@
(return arglist)))))
(defun ad-advised-interactive-form (function)
- ;;"Finds first interactive form in FUNCTION's redefining advices."
+ "Find first interactive form in FUNCTION's redefining advices."
(dolist (advice (append (ad-get-enabled-advices function 'before)
(ad-get-enabled-advices function 'around)
(ad-get-enabled-advices function 'after)))
@@ -2985,7 +2985,7 @@
;; ============================
(defun ad-make-advised-definition (function)
- ;;"Generates an advised definition of FUNCTION from its advice info."
+ "Generate an advised definition of FUNCTION from its advice info."
(if (and (ad-is-advised function)
(ad-has-redefining-advice function))
(let* ((origdef (ad-real-orig-definition function))
@@ -3129,7 +3129,7 @@
;; This is needed for activation/deactivation hooks:
(defun ad-make-hook-form (function hook-name)
- ;;"Makes hook-form from FUNCTION's advice bodies in class HOOK-NAME."
+ "Make hook-form from FUNCTION's advice bodies in class HOOK-NAME."
(let ((hook-forms
(mapcar (function (lambda (advice)
(ad-body-forms (ad-advice-definition advice))))
@@ -3217,7 +3217,7 @@
(ad-set-advice-info-field function 'cache nil))
(defun ad-make-cache-id (function)
- ;;"Generates an identifying image of the current advices of FUNCTION."
+ "Generate an identifying image of the current advices of FUNCTION."
(let ((original-definition (ad-real-orig-definition function))
(cached-definition (ad-get-cache-definition function)))
(list (mapcar (function (lambda (advice) (ad-advice-name advice)))
@@ -3236,7 +3236,7 @@
(ad-interactive-form cached-definition))))))
(defun ad-get-cache-class-id (function class)
- ;;"Returns the part of FUNCTION's cache id that identifies CLASS."
+ "Return the part of FUNCTION's cache id that identifies CLASS."
(let ((cache-id (ad-get-cache-id function)))
(if (eq class 'before)
(car cache-id)
@@ -3286,7 +3286,7 @@
code))
(defun ad-verify-cache-id (function)
- ;;"True if FUNCTION's cache-id is compatible with its current advices."
+ "True if FUNCTION's cache-id is compatible with its current advices."
(eq (ad-cache-id-verification-code function) 'verified))
@@ -3314,7 +3314,7 @@
;; advised definition will be generated.
(defun ad-preactivate-advice (function advice class position)
- ;;"Preactivates FUNCTION and returns the constructed cache."
+ "Preactivate FUNCTION and returns the constructed cache."
(let* ((function-defined-p (fboundp function))
(old-definition
(if function-defined-p
@@ -3426,11 +3426,11 @@
;; ======================================
(defun ad-should-compile (function compile)
- ;;"Returns non-nil if the advised FUNCTION should be compiled.
- ;;If COMPILE is non-nil and not a negative number then it returns t.
- ;;If COMPILE is a negative number then it returns nil.
- ;;If COMPILE is nil then the result depends on the value of
- ;;`ad-default-compilation-action' (which see)."
+ "Return non-nil if the advised FUNCTION should be compiled.
+If COMPILE is non-nil and not a negative number then it returns t.
+If COMPILE is a negative number then it returns nil.
+If COMPILE is nil then the result depends on the value of
+`ad-default-compilation-action' (which see)."
(if (integerp compile)
(>= compile 0)
(if compile
@@ -3446,9 +3446,9 @@
(t (featurep 'byte-compile))))))
(defun ad-activate-advised-definition (function compile)
- ;;"Redefines FUNCTION with its advised definition from cache or scratch.
- ;;The resulting FUNCTION will be compiled if `ad-should-compile' returns t.
- ;;The current definition and its cache-id will be put into the cache."
+ "Redefine FUNCTION with its advised definition from cache or scratch.
+The resulting FUNCTION will be compiled if `ad-should-compile' returns t.
+The current definition and its cache-id will be put into the cache."
(let ((verified-cached-definition
(if (ad-verify-cache-id function)
(ad-get-cache-definition function))))
https://bitbucket.org/xemacs/xemacs-base/changeset/080d3b71a1cc/
changeset: 080d3b71a1cc
user: kehoea
date: 2012-05-11 20:21:55
summary: Use standard backquotes, advice.el, old Emacs Lisp backquotes are long obsolete.
affected #: 2 files
diff -r 51d722692ee03cc29c3a708e66e4b46dc164a117 -r 080d3b71a1cc2953be541e3c57c4a9506ab05f63 ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -60,6 +60,8 @@
Uncomment the docstrings for these functions, they take up negligible
space these days.
+ Use standard backquotes, old Emacs Lisp backquotes are long obsolete.
+
2012-01-10 Norbert Koch <viteno(a)xemacs.org>
* Makefile (VERSION): XEmacs package 2.31 released.
diff -r 51d722692ee03cc29c3a708e66e4b46dc164a117 -r 080d3b71a1cc2953be541e3c57c4a9506ab05f63 advice.el
--- a/advice.el
+++ b/advice.el
@@ -1731,7 +1731,7 @@
;; `ad-return-value' in a piece of after advice. For example:
;;
;; (defmacro foom (x)
-;; (` (list (, x))))
+;; `(list ,x))
;; foom
;;
;; (foom '(a))
@@ -1763,9 +1763,7 @@
;;
;; (defadvice foom (after fg-print-x act)
;; "Print the value of X."
-;; (setq ad-return-value
-;; (` (progn (print (, x))
-;; (, ad-return-value)))))
+;; (setq ad-return-value `(progn (print ,x) ,ad-return-value)))
;; foom
;;
;; (macroexpand '(foom '(a)))
@@ -1879,15 +1877,15 @@
(let ((saved-function (intern (format "ad-real-%s" function))))
;; Make sure the compiler is loaded during macro expansion:
(require 'byte-compile "bytecomp")
- (` (if (not (fboundp '(, saved-function)))
- (progn (fset '(, saved-function) (symbol-function '(, function)))
- ;; Copy byte-compiler properties:
- (,@ (if (get function 'byte-compile)
- (` ((put '(, saved-function) 'byte-compile
- '(, (get function 'byte-compile)))))))
- (,@ (if (get function 'byte-opcode)
- (` ((put '(, saved-function) 'byte-opcode
- '(, (get function 'byte-opcode))))))))))))
+ `(if (not (fboundp ',saved-function))
+ (progn (fset ',saved-function (symbol-function ',function))
+ ;; Copy byte-compiler properties:
+ ,@(if (get function 'byte-compile)
+ `((put ',saved-function 'byte-compile
+ ',(get function 'byte-compile))))
+ ,@(if (get function 'byte-opcode)
+ `((put ',saved-function 'byte-opcode
+ ',(get function 'byte-opcode))))))))
(defun ad-save-real-definitions ()
;; Macro expansion will hardcode the values of the various byte-compiler
@@ -1923,16 +1921,15 @@
(defmacro ad-pushnew-advised-function (function)
"Add FUNCTION to `ad-advised-functions' unless its already there."
- (` (if (not (assoc (symbol-name (, function)) ad-advised-functions))
- (setq ad-advised-functions
- (cons (list (symbol-name (, function)))
- ad-advised-functions)))))
+ `(if (not (assoc (symbol-name ,function) ad-advised-functions))
+ (setq ad-advised-functions
+ (cons (list (symbol-name ,function)) ad-advised-functions))))
(defmacro ad-pop-advised-function (function)
"Remove FUNCTION from `ad-advised-functions'."
- (` (setq ad-advised-functions
- (delq (assoc (symbol-name (, function)) ad-advised-functions)
- ad-advised-functions))))
+ `(setq ad-advised-functions
+ (delq (assoc (symbol-name ,function) ad-advised-functions)
+ ad-advised-functions)))
(defmacro ad-do-advised-functions (varform &rest body)
"`dolist'-style iterator that maps over `ad-advised-functions'.
@@ -1940,23 +1937,21 @@
BODY-FORM...)
Also see `dolist'. On each iteration VAR will be bound to the
name of an advised function (a symbol)."
- (` (dolist ((, (car varform))
- ad-advised-functions
- (, (car (cdr varform))))
- (setq (, (car varform)) (intern (car (, (car varform)))))
- (,@ body))))
+ `(dolist (,(car varform) ad-advised-functions ,(car (cdr varform)))
+ (setq ,(car varform) (intern (car ,(car varform))))
+ ,@body))
(if (not (get 'ad-do-advised-functions 'lisp-indent-hook))
(put 'ad-do-advised-functions 'lisp-indent-hook 1))
(defmacro ad-get-advice-info (function)
- (` (get (, function) 'ad-advice-info)))
+ `(get ,function 'ad-advice-info))
(defmacro ad-set-advice-info (function advice-info)
- (` (put (, function) 'ad-advice-info (, advice-info))))
+ `(put ,function 'ad-advice-info ,advice-info))
(defmacro ad-copy-advice-info (function)
- (` (copy-tree (get (, function) 'ad-advice-info))))
+ `(copy-tree (get ,function 'ad-advice-info)))
(defmacro ad-is-advised (function)
"Return non-nil if FUNCTION has any advice info associated with it.
@@ -1971,7 +1966,7 @@
(defmacro ad-get-advice-info-field (function field)
"Retrieves the value of the advice info FIELD of FUNCTION."
- (` (cdr (assq (, field) (ad-get-advice-info (, function))))))
+ `(cdr (assq ,field (ad-get-advice-info ,function))))
(defun ad-set-advice-info-field (function field value)
"Destructively modifies VALUE of the advice info FIELD of FUNCTION."
@@ -2097,8 +2092,8 @@
(defvar ad-activate-on-top-level t)
(defmacro ad-with-auto-activation-disabled (&rest body)
- (` (let ((ad-activate-on-top-level nil))
- (,@ body))))
+ `(let ((ad-activate-on-top-level nil))
+ ,@body))
(defun ad-safe-fset (symbol definition)
"A safe `fset' which will never call `ad-activate' recursively."
@@ -2120,17 +2115,14 @@
(intern (format "ad-Orig-%s" function)))
(defmacro ad-get-orig-definition (function)
- (` (let ((origname (ad-get-advice-info-field (, function) 'origname)))
- (if (fboundp origname)
- (symbol-function origname)))))
+ `(let ((origname (ad-get-advice-info-field ,function 'origname)))
+ (if (fboundp origname) (symbol-function origname))))
(defmacro ad-set-orig-definition (function definition)
- (` (ad-safe-fset
- (ad-get-advice-info-field function 'origname) (, definition))))
+ `(ad-safe-fset (ad-get-advice-info-field function 'origname) ,definition))
(defmacro ad-clear-orig-definition (function)
- (` (fmakunbound (ad-get-advice-info-field (, function) 'origname))))
-
+ `(fmakunbound (ad-get-advice-info-field ,function 'origname)))
;; @@ Interactive input functions:
;; ===============================
@@ -2237,7 +2229,7 @@
(defmacro ad-find-advice (function class name)
"Find the first advice of FUNCTION in CLASS with NAME."
- (` (assq (, name) (ad-get-advice-info-field (, function) (, class)))))
+ `(assq ,name (ad-get-advice-info-field ,function ,class)))
(defun ad-advice-position (function class name)
"Return position of first advice of FUNCTION in CLASS with NAME."
@@ -2266,12 +2258,12 @@
(if found-advice (return found-advice))))))
(defun ad-enable-advice-internal (function class name flag)
- ;;"Sets enable FLAG of FUNCTION's advices in CLASS matching NAME.
- ;;If NAME is a string rather than a symbol then it's interpreted as a regular
- ;;expression and all advices whose name contain a match for it will be
- ;;affected. If CLASS is `any' advices in all legal advice classes will be
- ;;considered. The number of changed advices will be returned (or nil if
- ;;FUNCTION was not advised)."
+ "Set enable FLAG of FUNCTION's advices in CLASS matching NAME.
+If NAME is a string rather than a symbol then it's interpreted as a regular
+expression and all advices whose name contain a match for it will be
+affected. If CLASS is `any' advices in all legal advice classes will be
+considered. The number of changed advices will be returned (or nil if
+FUNCTION was not advised)."
(if (ad-is-advised function)
(let ((matched-advices 0))
(dolist (advice-class ad-advice-classes)
@@ -2394,33 +2386,33 @@
;; ===================================================
(defmacro ad-macrofy (definition)
- ;;"Takes a lambda function DEFINITION and makes a macro out of it."
- (` (cons 'macro (, definition))))
+ "Take a lambda function DEFINITION and make a macro out of it."
+ `(cons 'macro ,definition))
(defmacro ad-lambdafy (definition)
- ;;"Takes a macro function DEFINITION and makes a lambda out of it."
- (` (cdr (, definition))))
+ "Take a macro function DEFINITION and make a lambda out of it."
+ `(cdr ,definition))
(defmacro ad-interactive-p (definition)
- ;;"non-nil if DEFINITION can be called interactively."
+ "Non-nil if DEFINITION can be called interactively."
(list 'commandp definition))
(defmacro ad-subr-p (definition)
- ;;"non-nil if DEFINITION is a subr."
+ "Non-nil if DEFINITION is a subr."
(list 'subrp definition))
(defmacro ad-macro-p (definition)
- ;;"non-nil if DEFINITION is a macro."
- (` (eq (car-safe (, definition)) 'macro)))
+ "Non-nil if DEFINITION is a macro."
+ `(eq (car-safe ,definition) 'macro))
(defmacro ad-lambda-p (definition)
- ;;"non-nil if DEFINITION is a lambda expression."
- (` (eq (car-safe (, definition)) 'lambda)))
+ "Non-nil if DEFINITION is a lambda expression."
+ `(eq (car-safe ,definition) 'lambda))
;; see ad-make-advice for the format of advice definitions:
(defmacro ad-advice-p (definition)
- ;;"non-nil if DEFINITION is a piece of advice."
- (` (eq (car-safe (, definition)) 'advice)))
+ "Non-nil if DEFINITION is a piece of advice."
+ `(eq (car-safe ,definition) 'advice))
;; Emacs/XEmacs cross-compatibility
;; (compiled-function-p is an obsolete function in Emacs):
@@ -2430,15 +2422,15 @@
(defmacro ad-compiled-p (definition)
"Return non-nil if DEFINITION is a compiled byte-code object."
- (` (or (byte-code-function-p (, definition))
- (and (ad-macro-p (, definition))
- (byte-code-function-p (ad-lambdafy (, definition)))))))
+ `(or (byte-code-function-p ,definition)
+ (and (ad-macro-p ,definition)
+ (byte-code-function-p (ad-lambdafy ,definition)))))
(defmacro ad-compiled-code (compiled-definition)
"Return the byte-code object of a COMPILED-DEFINITION."
- (` (if (ad-macro-p (, compiled-definition))
- (ad-lambdafy (, compiled-definition))
- (, compiled-definition))))
+ `(if (ad-macro-p ,compiled-definition)
+ (ad-lambdafy ,compiled-definition)
+ ,compiled-definition))
(defun ad-lambda-expression (definition)
"Return the lambda expression of a function/macro/advice DEFINITION."
@@ -2473,13 +2465,13 @@
;; Store subr-args as `((arg1 arg2 ...))' so I can distinguish
;; a defined empty arglist `(nil)' from an undefined arglist:
(defmacro ad-define-subr-args (subr arglist)
- (` (put (, subr) 'ad-subr-arglist (list (, arglist)))))
+ `(put ,subr 'ad-subr-arglist (list ,arglist)))
(defmacro ad-undefine-subr-args (subr)
- (` (put (, subr) 'ad-subr-arglist nil)))
+ `(put ,subr 'ad-subr-arglist nil))
(defmacro ad-subr-args-defined-p (subr)
- (` (get (, subr) 'ad-subr-arglist)))
+ `(get ,subr 'ad-subr-arglist))
(defmacro ad-get-subr-args (subr)
- (` (car (get (, subr) 'ad-subr-arglist))))
+ `(car (get ,subr 'ad-subr-arglist)))
(defun ad-subr-arglist (subr-name)
"Retrieve arglist of the subr with SUBR-NAME.
@@ -2688,18 +2680,12 @@
element is its actual current value, and the third element is either
`required', `optional' or `rest' depending on the type of the argument."
(let* ((parsed-arglist (ad-parse-arglist arglist))
- (rest (nth 2 parsed-arglist)))
- (` (list
- (,@ (mapcar (function
- (lambda (req)
- (` (list '(, req) (, req) 'required))))
- (nth 0 parsed-arglist)))
- (,@ (mapcar (function
- (lambda (opt)
- (` (list '(, opt) (, opt) 'optional))))
- (nth 1 parsed-arglist)))
- (,@ (if rest (list (` (list '(, rest) (, rest) 'rest)))))
- ))))
+ (rest (nth 2 parsed-arglist)))
+ `(list ,@(mapcar #'(lambda (req) `(list ',req ,req 'required))
+ (nth 0 parsed-arglist))
+ ,@(mapcar #'(lambda (opt) `(list ',opt ,opt 'optional))
+ (nth 1 parsed-arglist))
+ ,@(if rest (list `(list ',rest ,rest 'rest))))))
(defun ad-arg-binding-field (binding field)
(cond ((eq field 'name) (car binding))
@@ -2713,7 +2699,7 @@
(defun ad-element-access (position list)
(cond ((= position 0) (list 'car list))
- ((= position 1) (` (car (cdr (, list)))))
+ ((= position 1) `(car (cdr ,list)))
(t (list 'nth position list))))
(defun ad-access-argument (arglist index)
@@ -2742,13 +2728,15 @@
(let ((argument-access (ad-access-argument arglist index)))
(cond ((consp argument-access)
;; should this check whether there actually is something to set?
- (` (setcar (, (ad-list-access
- (car argument-access) (car (cdr argument-access))))
- (, value-form))))
- (argument-access
- (` (setq (, argument-access) (, value-form))))
- (t (error "ad-set-argument: No argument at position %d of `%s'"
- index arglist)))))
+ `(setcar ,(ad-list-access (car argument-access)
+ (car (cdr argument-access)))
+ ,value-form))
+ (argument-access `(setq ,argument-access ,value-form))
+ (t
+ (error
+ "ad-set-argument: No argument at position %d of `%s'"
+ index
+ arglist)))))
(defun ad-get-arguments (arglist index)
"Returns form to access all actual arguments starting at position INDEX."
@@ -2758,12 +2746,13 @@
(rest-arg (nth 2 parsed-arglist))
args-form)
(if (< index (length reqopt-args))
- (setq args-form (` (list (,@ (nthcdr index reqopt-args))))))
+ (setq args-form `(list ,@(nthcdr index reqopt-args))))
(if rest-arg
- (if args-form
- (setq args-form (` (nconc (, args-form) (, rest-arg))))
- (setq args-form (ad-list-access (- index (length reqopt-args))
- rest-arg))))
+ (if args-form
+ (setq args-form `(nconc ,args-form ,rest-arg))
+ (setq
+ args-form
+ (ad-list-access (- index (length reqopt-args)) rest-arg))))
args-form))
(defun ad-set-arguments (arglist index values-form)
@@ -2799,10 +2788,10 @@
;; For exactly one set-form we can use values-form directly,...
(subst values-form 'ad-vAlUeS (car set-forms))
;; ...if we have more we have to bind it to a variable:
- (` (let ((ad-vAlUeS (, values-form)))
- (,@ (reverse set-forms))
- ;; work around the old backquote bug:
- (, 'ad-vAlUeS)))))))
+ `(let ((ad-vAlUeS ,values-form))
+ ,@(reverse set-forms)
+ ;; work around the old backquote bug:
+ ,'ad-vAlUeS)))))
(defun ad-insert-argument-access-forms (definition arglist)
"Expand arg-access text macros in DEFINITION according to ARGLIST."
@@ -3007,11 +2996,11 @@
;; we have to and initialize required arguments in case
;; it is called interactively:
(orig-interactive-p
- (let ((reqargs (car (ad-parse-arglist advised-arglist))))
- (if reqargs
- (` (interactive
- '(, (make-list (length reqargs) nil))))
- '(interactive))))))
+ (let ((reqargs
+ (car (ad-parse-arglist advised-arglist))))
+ (if reqargs
+ `(interactive ',(make-list (length reqargs) nil))
+ '(interactive))))))
(orig-form
(cond ((or orig-special-form-p orig-macro-p)
;; Special forms and macros will be advised into macros.
@@ -3028,20 +3017,18 @@
;; expansion time and return the result. The moral of that
;; is that one should always deactivate advised special
;; forms before one byte-compiles a file.
- (` ((, (if orig-macro-p
- 'macroexpand
- 'eval))
- (cons '(, origname)
- (, (ad-get-arguments advised-arglist 0))))))
- ((and orig-subr-p
- orig-interactive-p
- (not advised-interactive-form))
+ `(,(if orig-macro-p 'macroexpand 'eval)
+ (cons ',origname
+ ,(ad-get-arguments advised-arglist 0))))
+ ((and orig-subr-p
+ orig-interactive-p
+ (not advised-interactive-form))
;; Check whether we were called interactively
;; in order to do proper prompting:
- (` (if (interactive-p)
- (call-interactively '(, origname))
- (, (ad-make-mapped-call
- orig-arglist advised-arglist origname)))))
+ `(if (interactive-p)
+ (call-interactively ',origname)
+ ,(ad-make-mapped-call orig-arglist advised-arglist
+ origname)))
;; And now for normal functions and non-interactive subrs
;; (or subrs whose interactive behavior was advised):
(t (ad-make-mapped-call
@@ -3074,18 +3061,16 @@
(let (before-forms around-form around-form-protected after-forms definition)
(dolist (advice befores)
- (cond ((and (ad-advice-protected advice)
- before-forms)
- (setq before-forms
- (` ((unwind-protect
- (, (ad-prognify before-forms))
- (,@ (ad-body-forms
- (ad-advice-definition advice))))))))
- (t (setq before-forms
- (append before-forms
- (ad-body-forms (ad-advice-definition advice)))))))
-
- (setq around-form (` (setq ad-return-value (, orig))))
+ (cond ((and (ad-advice-protected advice) before-forms)
+ (setq before-forms
+ `((unwind-protect
+ ,(ad-prognify before-forms)
+ ,@(ad-body-forms (ad-advice-definition advice))))))
+ (t
+ (setq before-forms
+ (append before-forms
+ (ad-body-forms (ad-advice-definition advice)))))))
+ (setq around-form `(setq ad-return-value ,orig))
(dolist (advice (reverse arounds))
;; If any of the around advices is protected then we
;; protect the complete around advice onion:
@@ -3096,35 +3081,27 @@
(ad-prognify
(ad-body-forms (ad-advice-definition advice))))))
(setq after-forms
- (if (and around-form-protected before-forms)
- (` ((unwind-protect
- (, (ad-prognify before-forms))
- (, around-form))))
- (append before-forms (list around-form))))
+ (if (and around-form-protected before-forms)
+ `((unwind-protect ,(ad-prognify before-forms) ,around-form))
+ (append before-forms (list around-form))))
(dolist (advice afters)
- (cond ((and (ad-advice-protected advice)
- after-forms)
- (setq after-forms
- (` ((unwind-protect
- (, (ad-prognify after-forms))
- (,@ (ad-body-forms
- (ad-advice-definition advice))))))))
- (t (setq after-forms
- (append after-forms
- (ad-body-forms (ad-advice-definition advice)))))))
-
+ (cond ((and (ad-advice-protected advice) after-forms)
+ (setq after-forms
+ `((unwind-protect ,(ad-prognify after-forms)
+ ,@(ad-body-forms (ad-advice-definition advice))))))
+ (t
+ (setq after-forms
+ (append after-forms
+ (ad-body-forms (ad-advice-definition advice)))))))
(setq definition
- (` ((,@ (if (memq type '(macro special-form)) '(macro)))
- lambda
- (, args)
- (,@ (if docstring (list docstring)))
- (,@ (if interactive (list interactive)))
- (let (ad-return-value)
- (,@ after-forms)
- (, (if (eq type 'special-form)
- '(list 'quote ad-return-value)
- 'ad-return-value))))))
-
+ `(,@(if (memq type '(macro special-form)) '(macro))
+ lambda ,args ,@(if docstring (list docstring))
+ ,@(if interactive (list interactive))
+ (let (ad-return-value)
+ ,@after-forms
+ ,(if (eq type 'special-form)
+ '(list 'quote ad-return-value)
+ 'ad-return-value))))
(ad-insert-argument-access-forms definition args)))
;; This is needed for activation/deactivation hooks:
@@ -3199,14 +3176,13 @@
;; a lot cheaper than reconstructing an advised definition.
(defmacro ad-get-cache-definition (function)
- (` (car (ad-get-advice-info-field (, function) 'cache))))
+ `(car (ad-get-advice-info-field ,function 'cache)))
(defmacro ad-get-cache-id (function)
- (` (cdr (ad-get-advice-info-field (, function) 'cache))))
+ `(cdr (ad-get-advice-info-field ,function 'cache)))
(defmacro ad-set-cache (function definition id)
- (` (ad-set-advice-info-field
- (, function) 'cache (cons (, definition) (, id)))))
+ `(ad-set-advice-info-field ,function 'cache (cons ,definition ,id)))
(defun ad-clear-cache (function)
"Clears a previously cached advised definition of FUNCTION.
@@ -3407,20 +3383,17 @@
(ad-safe-fset 'ad-make-origname real-origname-fn))))
(if frozen-definition
(let* ((macro-p (ad-macro-p frozen-definition))
- (body (cdr (if macro-p
- (ad-lambdafy frozen-definition)
- frozen-definition))))
- (` (progn
- (if (not (fboundp '(, unique-origname)))
- (fset '(, unique-origname)
- ;; avoid infinite recursion in case the function
- ;; we want to freeze is already advised:
- (or (ad-get-orig-definition '(, function))
- (symbol-function '(, function)))))
- ((, (if macro-p 'defmacro 'defun))
- (, function)
- (,@ body))))))))
-
+ (body (cdr (if macro-p
+ (ad-lambdafy frozen-definition)
+ frozen-definition))))
+ `(progn
+ (if (not (fboundp ',unique-origname))
+ ;; avoid infinite recursion in case the function
+ ;; we want to freeze is already advised:
+ (fset ',unique-origname
+ (or (ad-get-orig-definition ',function)
+ (symbol-function ',function))))
+ (,(if macro-p 'defmacro 'defun) ,function ,@body))))))
;; @@ Activation and definition handling:
;; ======================================
@@ -3552,7 +3525,7 @@
(t (ad-deactivate function)))))))))
(defun ad-deactivate (function)
- "Deactivates the advice of an actively advised FUNCTION.
+ "Deactivate the advice of an actively advised FUNCTION.
If FUNCTION has a proper original definition, then the current
definition of FUNCTION will be replaced with it. All the advice
information will still be available so it can be activated again with
@@ -3755,10 +3728,9 @@
(t (error "defadvice: Illegal or ambiguous flag: %s"
flag))))))
args))
- (advice (ad-make-advice
- name (memq 'protect flags)
- (not (memq 'disable flags))
- (` (advice lambda (, arglist) (,@ body)))))
+ (advice (ad-make-advice name (memq 'protect flags)
+ (not (memq 'disable flags))
+ `(advice lambda ,arglist ,@body)))
(preactivation (if (memq 'preactivate flags)
(ad-preactivate-advice
function advice class position))))
@@ -3766,27 +3738,21 @@
(if (memq 'freeze flags)
;; jwz's idea: Freeze the advised definition into a dumpable
;; defun/defmacro whose docs can be written to the DOC file:
- (ad-make-freeze-definition function advice class position)
- ;; the normal case:
- (` (progn
- (ad-add-advice '(, function) '(, advice) '(, class) '(, position))
- (,@ (if preactivation
- (` ((ad-set-cache
- '(, function)
- ;; the function will get compiled:
- (, (cond ((ad-macro-p (car preactivation))
- (` (ad-macrofy
- (function
- (, (ad-lambdafy
- (car preactivation)))))))
- (t (` (function
- (, (car preactivation)))))))
- '(, (car (cdr preactivation))))))))
- (,@ (if (memq 'activate flags)
- (` ((ad-activate-on '(, function)
- (, (if (memq 'compile flags) t)))))))
- '(, function))))))
-
+ (ad-make-freeze-definition function advice class position)
+ ;; the normal case:
+ `(progn (ad-add-advice ',function ',advice ',class ',position)
+ ,@(if preactivation
+ `((ad-set-cache
+ ',function
+ ,(cond ((ad-macro-p (car preactivation))
+ `(ad-macrofy
+ #',(ad-lambdafy (car preactivation))))
+ (t `#',(car preactivation)))
+ ',(car (cdr preactivation)))))
+ ,@(if (memq 'activate flags)
+ `((ad-activate-on ',function
+ ,(if (memq 'compile flags) t))))
+ ',function))))
;; @@ Tools:
;; =========
@@ -3801,39 +3767,35 @@
(current-bindings
(mapcar (function
(lambda (function)
- (setq index (1+ index))
- (list (intern (format "ad-oRiGdEf-%d" index))
- (` (symbol-function '(, function))))))
+ (setq index (1+ index))
+ (list
+ (intern (format "ad-oRiGdEf-%d" index))
+ `(symbol-function ',function))))
functions)))
- (` (let (, current-bindings)
- (unwind-protect
- (progn
- (,@ (progn
+ `(let ,current-bindings
+ (unwind-protect
+ (progn ,@(progn
;; Make forms to redefine functions to their
;; original definitions if they are advised:
- (setq index -1)
- (mapcar
- (function
- (lambda (function)
- (setq index (1+ index))
- (` (ad-safe-fset
- '(, function)
- (or (ad-get-orig-definition '(, function))
- (, (car (nth index current-bindings))))))))
- functions)))
- (,@ body))
- (,@ (progn
- ;; Make forms to back-define functions to the definitions
- ;; they had outside this macro call:
- (setq index -1)
- (mapcar
- (function
- (lambda (function)
- (setq index (1+ index))
- (` (ad-safe-fset
- '(, function)
- (, (car (nth index current-bindings)))))))
- functions))))))))
+ (setq index -1)
+ (mapcar
+ #'(lambda (function)
+ (setq index (1+ index))
+ `(ad-safe-fset ',function
+ (or (ad-get-orig-definition ',function)
+ ,(car (nth index current-bindings)))))
+ functions))
+ ,@body)
+ ,@(progn
+ ;; Make forms to back-define functions to the definitions
+ ;; they had outside this macro call:
+ (setq index -1)
+ (mapcar
+ #'(lambda (function)
+ (setq index (1+ index))
+ `(ad-safe-fset ',function
+ ,(car (nth index current-bindings))))
+ functions))))))
(if (not (get 'ad-with-originals 'lisp-indent-hook))
(put 'ad-with-originals 'lisp-indent-hook 1))
Repository URL: https://bitbucket.org/xemacs/xemacs-base/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
commit/xemacs-packages: 3 new changesets
12 years, 7 months
Bitbucket
3 new commits in xemacs-packages:
https://bitbucket.org/xemacs/xemacs-packages/changeset/95f93fc230dd/
changeset: 95f93fc230dd
user: Norbert Koch
date: 2012-05-11 16:39:31
summary: Update w3
affected #: 1 file
diff -r 397f8db0c64ecdca35508d4c74c767816fb23ef9 -r 95f93fc230dd00eff53519b8031748a46047e2d6 .hgsubstate
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -121,7 +121,7 @@
3dd48bd9d10d44702d655ead107f32a78560c243 xemacs-packages/view-process
b494b72f71b50f624e75e7614cd1d6b6d257d728 xemacs-packages/viper
4eb09b852b72373e7ce9790cb9ebafc7e1b7598e xemacs-packages/vm
-f1345b7a65c3b574fb2ccc6873429be0a067214f xemacs-packages/w3
+7c14b4d274fe9f0014c2ea75877177ae59e77fce xemacs-packages/w3
fd7cd3bdb22b444b112299facd2375daa2091dee xemacs-packages/x-symbol
d56f8e5d14021584dbef7f97c5985c36f19980cf xemacs-packages/xemacs-base
9c8d90ff018391ccc55abcf6967ea6a00e749f53 xemacs-packages/xemacs-devel
https://bitbucket.org/xemacs/xemacs-packages/changeset/2327f0c5c3dc/
changeset: 2327f0c5c3dc
user: Norbert Koch
date: 2012-05-11 16:40:15
summary: XEmacs Package Release
affected #: 1 file
diff -r 95f93fc230dd00eff53519b8031748a46047e2d6 -r 2327f0c5c3dc513f1e83d627534450ab64953e15 ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-05-11 Norbert Koch <viteno(a)xemacs.org>
+
+ * Packages released: w3.
+
2012-04-23 Norbert Koch <viteno(a)xemacs.org>
* Packages released: cc-mode.
https://bitbucket.org/xemacs/xemacs-packages/changeset/31e8227f1580/
changeset: 31e8227f1580
user: Norbert Koch
date: 2012-05-11 16:52:15
summary: Prerelease w3
affected #: 1 file
diff -r 2327f0c5c3dc513f1e83d627534450ab64953e15 -r 31e8227f15804846acdd87d43f92868976a5ae9d .hgsubstate
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -121,7 +121,7 @@
3dd48bd9d10d44702d655ead107f32a78560c243 xemacs-packages/view-process
b494b72f71b50f624e75e7614cd1d6b6d257d728 xemacs-packages/viper
4eb09b852b72373e7ce9790cb9ebafc7e1b7598e xemacs-packages/vm
-7c14b4d274fe9f0014c2ea75877177ae59e77fce xemacs-packages/w3
+59e99a00a59ffa39e51bb866ca30f2ec426459ee xemacs-packages/w3
fd7cd3bdb22b444b112299facd2375daa2091dee xemacs-packages/x-symbol
d56f8e5d14021584dbef7f97c5985c36f19980cf xemacs-packages/xemacs-base
9c8d90ff018391ccc55abcf6967ea6a00e749f53 xemacs-packages/xemacs-devel
Repository URL: https://bitbucket.org/xemacs/xemacs-packages/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches