]> code.delx.au - gnu-emacs/blobdiff - lisp/subr.el
Fix typo in previous change.
[gnu-emacs] / lisp / subr.el
index 220560464165c182221dc9a1eb4164df8046a326..fb22bc02654f3a4d175e6e626887ce606d80926b 100644 (file)
@@ -43,17 +43,13 @@ BODY should be a list of lisp expressions."
   ;; depend on backquote.el.
   (list 'function (cons 'lambda cdr)))
 
-;;(defmacro defun-inline (name args &rest body)
-;;  "Create an \"inline defun\" (actually a macro).
-;;Use just like `defun'."
-;;  (nconc (list 'defmacro name '(&rest args))
-;;      (if (stringp (car body))
-;;          (prog1 (list (car body))
-;;            (setq body (or (cdr body) body))))
-;;      (list (list 'cons (list 'quote
-;;                              (cons 'lambda (cons args body)))
-;;                  'args))))
+(defmacro when (cond &rest body)
+  "(when COND BODY...): if COND yields non-nil, do BODY, else return nil."
+  (list 'if cond (cons 'progn body)))
 
+(defmacro unless (cond &rest body)
+  "(unless COND BODY...): if COND yields nil, do BODY, else return nil."
+  (cons 'if (cons cond (cons nil body))))
 \f
 ;;;; Keymap support.
 
@@ -796,7 +792,7 @@ See also `with-temp-file' and `with-output-to-string'."
 If BODY makes changes in the buffer, they are recorded
 and the functions on `after-change-functions' are called several times
 when BODY is finished.
-The return value is rthe value of the last form in BODY.
+The return value is the value of the last form in BODY.
 
 If `before-change-functions' is non-nil, then calls to the after-change
 functions can't be deferred, so in that case this macro has no effect.
@@ -896,6 +892,22 @@ syntax table; other characters are copied from the standard syntax table."
        (aset table i nil)
        (setq i (1+ i)))
       table)))
+
+(defun add-to-invisibility-spec (arg)
+  "Add elements to `buffer-invisibility-spec'.
+See documentation for `buffer-invisibility-spec' for the kind of elements
+that can be added."
+  (cond
+   ((or (null buffer-invisibility-spec) (eq buffer-invisibility-spec t))
+       (setq buffer-invisibility-spec (list arg)))
+   (t
+    (setq buffer-invisibility-spec 
+         (nconc buffer-invisibility-spec (list arg))))))
+
+(defun remove-from-invisibility-spec (arg)
+  "Remove elements from `buffer-invisibility-spec'."
+  (if buffer-invisibility-spec
+    (setq buffer-invisibility-spec (delete arg buffer-invisibility-spec))))
 \f
 (defun global-set-key (key command)
   "Give KEY a global binding as COMMAND.
@@ -972,4 +984,3 @@ configuration."
 ;  alist)
 
 ;;; subr.el ends here
-