emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs etc/NEWS lisp/ChangeLog lisp/help-fns.el ...


From: Stefan Monnier
Subject: [Emacs-diffs] emacs etc/NEWS lisp/ChangeLog lisp/help-fns.el ...
Date: Thu, 01 Oct 2009 16:54:25 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        09/10/01 16:54:25

Modified files:
        etc            : NEWS 
        lisp           : ChangeLog help-fns.el 
        lisp/emacs-lisp: byte-run.el bytecomp.el 

Log message:
        * emacs-lisp/byte-run.el (advertised-signature-table): New var.
        (set-advertised-calling-convention): New function.
        (make-obsolete, define-obsolete-function-alias)
        (make-obsolete-variable, define-obsolete-variable-alias):
        Make the optional-ness of `when' obsolete.
        (define-obsolete-face-alias): Make `when' non-optional.
        * help-fns.el (help-function-arglist):
        * emacs-lisp/bytecomp.el (byte-compile-fdefinition):
        Use advertised-signature-table.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/etc/NEWS?cvsroot=emacs&r1=1.2095&r2=1.2096
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16315&r2=1.16316
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/help-fns.el?cvsroot=emacs&r1=1.140&r2=1.141
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/emacs-lisp/byte-run.el?cvsroot=emacs&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/emacs-lisp/bytecomp.el?cvsroot=emacs&r1=2.264&r2=2.265

Patches:
Index: etc/NEWS
===================================================================
RCS file: /sources/emacs/emacs/etc/NEWS,v
retrieving revision 1.2095
retrieving revision 1.2096
diff -u -b -r1.2095 -r1.2096
--- etc/NEWS    1 Oct 2009 15:50:43 -0000       1.2095
+++ etc/NEWS    1 Oct 2009 16:54:21 -0000       1.2096
@@ -246,6 +246,8 @@
 
 * Lisp changes in Emacs 23.2
 
+** New function set-advertised-calling-convention makes it possible
+to obsolete arguments as well as make some arguments mandatory.
 ** eval-next-after-load is obsolete.
 ** New hook `after-load-functions' run after loading an Elisp file.
 

Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16315
retrieving revision 1.16316
diff -u -b -r1.16315 -r1.16316
--- lisp/ChangeLog      1 Oct 2009 15:40:59 -0000       1.16315
+++ lisp/ChangeLog      1 Oct 2009 16:54:22 -0000       1.16316
@@ -1,3 +1,15 @@
+2009-10-01  Stefan Monnier  <address@hidden>
+
+       * emacs-lisp/byte-run.el (advertised-signature-table): New var.
+       (set-advertised-calling-convention): New function.
+       (make-obsolete, define-obsolete-function-alias)
+       (make-obsolete-variable, define-obsolete-variable-alias):
+       Make the optional-ness of `when' obsolete.
+       (define-obsolete-face-alias): Make `when' non-optional.
+       * help-fns.el (help-function-arglist):
+       * emacs-lisp/bytecomp.el (byte-compile-fdefinition):
+       Use advertised-signature-table.
+
 2009-10-01  Michael Albinus  <address@hidden>
 
        * files.el (delete-directory): New defun.  The original function
@@ -11,16 +23,15 @@
 
        * net/tramp.el (tramp-handle-make-directory): Flush upper
        directory's file properties.
-       (tramp-handle-delete-directory): Handle optional parameter
-       RECURSIVE.
+       (tramp-handle-delete-directory): Handle optional parameter RECURSIVE.
        (tramp-handle-dired-recursive-delete-directory): Flush directory
        properties after the remove command only.
 
-       * net/tramp-fish.el (tramp-fish-handle-delete-directory): Handle
-       optional parameter RECURSIVE.
+       * net/tramp-fish.el (tramp-fish-handle-delete-directory):
+       Handle optional parameter RECURSIVE.
 
-       * net/tramp-gvfs.el (tramp-gvfs-handle-delete-directory): Handle
-       optional parameter RECURSIVE.
+       * net/tramp-gvfs.el (tramp-gvfs-handle-delete-directory):
+       Handle optional parameter RECURSIVE.
 
        * net/tramp-smb.el (tramp-smb-errors): Add error message for
        connection timeout.

Index: lisp/help-fns.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/help-fns.el,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -b -r1.140 -r1.141
--- lisp/help-fns.el    24 Sep 2009 19:19:46 -0000      1.140
+++ lisp/help-fns.el    1 Oct 2009 16:54:24 -0000       1.141
@@ -100,13 +100,15 @@
   ;; Handle symbols aliased to other symbols.
   (if (and (symbolp def) (fboundp def)) (setq def (indirect-function def)))
   ;; If definition is a macro, find the function inside it.
+  (let ((advertised (gethash def advertised-signature-table t)))
+    (if (listp advertised) advertised
   (if (eq (car-safe def) 'macro) (setq def (cdr def)))
   (cond
    ((byte-code-function-p def) (aref def 0))
    ((eq (car-safe def) 'lambda) (nth 1 def))
    ((and (eq (car-safe def) 'autoload) (not (eq (nth 4 def) 'keymap)))
     "[Arg list not available until function definition is loaded.]")
-   (t t)))
+       (t t)))))
 
 (defun help-make-usage (function arglist)
   (cons (if (symbolp function) function 'anonymous)

Index: lisp/emacs-lisp/byte-run.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/byte-run.el,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- lisp/emacs-lisp/byte-run.el 31 Aug 2009 01:32:36 -0000      1.38
+++ lisp/emacs-lisp/byte-run.el 1 Oct 2009 16:54:25 -0000       1.39
@@ -106,6 +106,15 @@
      (eval-and-compile
        (put ',name 'byte-optimizer 'byte-compile-inline-expand))))
 
+(defvar advertised-signature-table (make-hash-table :test 'eq :weakness 'key))
+
+(defun set-advertised-calling-convention (function signature)
+  "Set the advertised SIGNATURE of FUNCTION.
+This will allow the byte-compiler to warn the programmer when she uses
+an obsolete calling convention."
+  (puthash (indirect-function function) signature
+           advertised-signature-table))
+
 (defun make-obsolete (obsolete-name current-name &optional when)
   "Make the byte-compiler warn that OBSOLETE-NAME is obsolete.
 The warning will say that CURRENT-NAME should be used instead.
@@ -120,6 +129,9 @@
       (put obsolete-name 'byte-compile 'byte-compile-obsolete))
     (put obsolete-name 'byte-obsolete-info (list current-name handler when)))
   obsolete-name)
+(set-advertised-calling-convention
+ ;; New code should always provide the `when' argument.
+ 'make-obsolete '(obsolete-name current-name when))
 
 (defmacro define-obsolete-function-alias (obsolete-name current-name
                                                   &optional when docstring)
@@ -137,6 +149,10 @@
   `(progn
      (defalias ,obsolete-name ,current-name ,docstring)
      (make-obsolete ,obsolete-name ,current-name ,when)))
+(set-advertised-calling-convention
+ ;; New code should always provide the `when' argument.
+ 'define-obsolete-function-alias
+ '(obsolete-name current-name when &optional docstring))
 
 (defun make-obsolete-variable (obsolete-name current-name &optional when)
   "Make the byte-compiler warn that OBSOLETE-NAME is obsolete.
@@ -152,6 +168,9 @@
     (car (read-from-string (read-string "Obsoletion replacement: ")))))
   (put obsolete-name 'byte-obsolete-variable (cons current-name when))
   obsolete-name)
+(set-advertised-calling-convention
+ ;; New code should always provide the `when' argument.
+ 'make-obsolete-variable '(obsolete-name current-name when))
 
 (defmacro define-obsolete-variable-alias (obsolete-name current-name
                                                 &optional when docstring)
@@ -179,14 +198,17 @@
   `(progn
      (defvaralias ,obsolete-name ,current-name ,docstring)
      (make-obsolete-variable ,obsolete-name ,current-name ,when)))
+(set-advertised-calling-convention
+ ;; New code should always provide the `when' argument.
+ 'define-obsolete-variable-alias
+ '(obsolete-name current-name when &optional docstring))
 
 ;; FIXME This is only defined in this file because the variable- and
 ;; function- versions are too.  Unlike those two, this one is not used
 ;; by the byte-compiler (would be nice if it could warn about obsolete
 ;; faces, but it doesn't really do anything special with faces).
 ;; It only really affects M-x describe-face output.
-(defmacro define-obsolete-face-alias (obsolete-face current-face
-                                                   &optional when)
+(defmacro define-obsolete-face-alias (obsolete-face current-face when)
   "Make OBSOLETE-FACE a face alias for CURRENT-FACE and mark it obsolete.
 The optional string WHEN gives the Emacs version where OBSOLETE-FACE
 became obsolete."

Index: lisp/emacs-lisp/bytecomp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/bytecomp.el,v
retrieving revision 2.264
retrieving revision 2.265
diff -u -b -r2.264 -r2.265
--- lisp/emacs-lisp/bytecomp.el 1 Oct 2009 04:38:55 -0000       2.264
+++ lisp/emacs-lisp/bytecomp.el 1 Oct 2009 16:54:25 -0000       2.265
@@ -1230,11 +1230,11 @@
 
 ;;; sanity-checking arglists
 
-;; If a function has an entry saying (FUNCTION . t).
-;; that means we know it is defined but we don't know how.
-;; If a function has an entry saying (FUNCTION . nil),
-;; that means treat it as not defined.
 (defun byte-compile-fdefinition (name macro-p)
+  ;; If a function has an entry saying (FUNCTION . t).
+  ;; that means we know it is defined but we don't know how.
+  ;; If a function has an entry saying (FUNCTION . nil),
+  ;; that means treat it as not defined.
   (let* ((list (if macro-p
                   byte-compile-macro-environment
                 byte-compile-function-environment))
@@ -1248,16 +1248,18 @@
                          (and (not macro-p)
                               (byte-code-function-p (symbol-function fn)))))
            (setq fn (symbol-function fn)))
-         (if (and (not macro-p) (byte-code-function-p fn))
-             fn
-           (and (consp fn)
-                (if (eq 'macro (car fn))
-                    (cdr fn)
+          (let ((advertised (gethash fn advertised-signature-table t)))
+            (cond
+             ((listp advertised)
                   (if macro-p
-                      nil
-                    (if (eq 'autoload (car fn))
-                        nil
-                      fn)))))))))
+                  `(macro lambda ,advertised)
+                `(lambda ,advertised)))
+             ((and (not macro-p) (byte-code-function-p fn)) fn)
+             ((not (consp fn)) nil)
+             ((eq 'macro (car fn)) (cdr fn))
+             (macro-p nil)
+             ((eq 'autoload (car fn)) nil)
+             (t fn)))))))
 
 (defun byte-compile-arglist-signature (arglist)
   (let ((args 0)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]