X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=poe.el;h=6a8fbffb8d852ae900f974b9e628ba35ad39a5ba;hb=61a3463a8ae10a4c3c8dc192fdc2e61d139250a7;hp=0e778466666fd11b934b81df098bf455cd9ddd31;hpb=cd1f8452827eca227aaa47ea5fbeff3476849920;p=elisp%2Fapel.git diff --git a/poe.el b/poe.el index 0e77846..6a8fbff 100644 --- a/poe.el +++ b/poe.el @@ -29,6 +29,8 @@ ;;; Code: +(provide 'poe) + (defmacro defun-maybe (name &rest everything-else) (or (and (fboundp name) (not (get name 'defun-maybe))) @@ -101,26 +103,27 @@ ))) (defmacro defun-maybe-cond (name args &optional doc &rest everything-else) - (unless (stringp doc) - (setq everything-else (cons doc everything-else) - doc nil) - ) + (or (stringp doc) + (setq everything-else (cons doc everything-else) + doc nil) + ) (or (and (fboundp name) (not (get name 'defun-maybe))) - (` (unless (fboundp (quote (, name))) - (cond (,@ (mapcar (function - (lambda (case) - (list (car case) - (if doc - (` (defun (, name) (, args) - (, doc) - (,@ (cdr case)))) - (` (defun (, name) (, args) - (,@ (cdr case)))) - )))) - everything-else))) - (put (quote (, name)) 'defun-maybe t) - )))) + (` (or (fboundp (quote (, name))) + (progn + (cond (,@ (mapcar (function + (lambda (case) + (list (car case) + (if doc + (` (defun (, name) (, args) + (, doc) + (,@ (cdr case)))) + (` (defun (, name) (, args) + (,@ (cdr case)))) + )))) + everything-else))) + (put (quote (, name)) 'defun-maybe t) + ))))) (defsubst subr-fboundp (symbol) "Return t if SYMBOL's function definition is a built-in function." @@ -156,7 +159,6 @@ (require 'poe-18) )) - ;;; @ Emacs 19.23 emulation ;;; @@ -220,22 +222,35 @@ The value is actually the element of LIST whose cdr equals KEY." (setq list (cdr list))) )) -(defmacro-maybe make-local-hook (hook)) - -;; They are not Emacs features - +(defun-maybe file-name-sans-extension (filename) + "Return FILENAME sans final \"extension\". +The extension, in a file name, is the part that follows the last `.'." + (save-match-data + (let ((file (file-name-sans-versions (file-name-nondirectory filename))) + directory) + (if (string-match "\\.[^.]*\\'" file) + (if (setq directory (file-name-directory filename)) + (expand-file-name (substring file 0 (match-beginning 0)) + directory) + (substring file 0 (match-beginning 0))) + filename)))) + +;; It is not Emacs feature. (defmacro-maybe add-local-hook (hook function &optional append) (if (fboundp 'make-local-hook) (list 'add-hook hook function append t) (list 'add-hook hook function append) )) +;; It is not Emacs feature. (defmacro-maybe remove-local-hook (hook function) (if (fboundp 'make-local-hook) (list 'remove-hook hook function t) (list 'remove-hook hook function) )) +(defmacro-maybe make-local-hook (hook)) + ;;; @ Emacs 19.30 emulation ;;; @@ -564,6 +579,4 @@ If the event isn't a keypress, this returns nil. ;;; @ end ;;; -(provide 'poe) - ;;; poe.el ends here