diff options
author | Ronan Waide <waider@waider.ie> | 2002-01-06 22:05:49 +0000 |
---|---|---|
committer | Ronan Waide <waider@waider.ie> | 2002-01-06 22:05:49 +0000 |
commit | 5e8cfa2e848e29010b47f741edb80ed009f1d97c (patch) | |
tree | 780b7b3144d688be01438f94d10b1f207f53c2c8 /lisp | |
parent | 866aa67c2ef2ba4a8446acba382b8377e59dfec5 (diff) |
Compiler cleanup
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/bbdb-com.el | 38 | ||||
-rw-r--r-- | lisp/bbdb-ftp.el | 90 | ||||
-rw-r--r-- | lisp/bbdb-gui.el | 16 | ||||
-rw-r--r-- | lisp/bbdb-hooks.el | 20 | ||||
-rw-r--r-- | lisp/bbdb-snarf.el | 28 | ||||
-rw-r--r-- | lisp/bbdb-w3.el | 48 | ||||
-rw-r--r-- | lisp/bbdb.el | 10 |
7 files changed, 119 insertions, 131 deletions
diff --git a/lisp/bbdb-com.el b/lisp/bbdb-com.el index 2ee0bfa..c9dc440 100644 --- a/lisp/bbdb-com.el +++ b/lisp/bbdb-com.el @@ -34,6 +34,32 @@ (quote mailabbrev) (quote mail-abbrevs)))) +;; compiler placating. +;; not sure this is necessary, but best not to break things +(eval-and-compile + (or (boundp 'auto-fill-function) + (fset 'auto-fill-function 'auto-fill-hook))) + +(eval-when-compile + (autoload 'mh-send "mh-e") + (autoload 'vm-session-initialization "vm-startup.el") + (autoload 'vm-mail-internal "vm-reply.el") + (autoload 'mew-send "mew") + (autoload 'bbdb-header-start "bbdb-hooks") + (autoload 'bbdb-extract-field-value "bbdb-hooks") + (autoload 'Info-goto-node "info") + ;; this is very unpleasant, but saves me doing a lot of rewriting + ;; for now. a big cleanup will happen for the next release, maybe. + ;; NB if emacs 21 or older emacsen or even things you bolt on have + ;; any of these functions, bad things will happen. Again, FITNR. + (if (featurep 'xemacs) + () + (fset 'extent-string 'ignore) + (fset 'play-sound 'ignore) + (fset 'next-event 'ignore) + (fset 'display-message 'ignore) + (fset 'event-to-character 'ignore)) + ) (defcustom bbdb-default-country '"Emacs" ;; what do you mean, it's not a country? @@ -2133,7 +2159,7 @@ Completion behaviour can be controlled with `bbdb-completion-type'." (bbdb-record-net rec))) (delete-region beg end) (switch-to-buffer standard-output)) - ;; use next address + ;; use next address (let* ((addrs (bbdb-record-net rec)) (this-addr (or (cadr (member (cadar addr) addrs)) (nth 0 addrs)))) @@ -2198,10 +2224,7 @@ Completion behaviour can be controlled with `bbdb-completion-type'." (insert (bbdb-dwim-net-address (car match-recs) the-net)) ;; if we're past fill-column, wrap at the previous comma. - (if (and - (if (boundp 'auto-fill-function) ; the GNU Emacs name. - auto-fill-function - auto-fill-hook) + (if (and auto-fill-function (>= (current-column) fill-column)) (let ((p (point)) bol) @@ -2501,6 +2524,11 @@ modem or the like." :group 'bbdb-phone-dialing :type 'string) +(defcustom bbdb-sound-volume 0 + "Volume to play touchtones at." + :group 'bbdb-phone-dialing + :type 'number) + (defun bbdb-dial-number (phone-string) "Play the touchtone corresponding to the numbers in string." (interactive "sTelephonenumber: ") diff --git a/lisp/bbdb-ftp.el b/lisp/bbdb-ftp.el index 2ab313b..70e20a4 100644 --- a/lisp/bbdb-ftp.el +++ b/lisp/bbdb-ftp.el @@ -23,32 +23,6 @@ ;; $Date$ by $Author$ ;; $Revision$ -;; -;; $Log$ -;; Revision 1.58 2000/07/20 21:40:40 sds -;; * lisp/bbdb-com.el (bbdb-finger): use `bbdb-get-record' -;; * lisp/bbdb-whois.el (bbdb-whois): use `bbdb-get-record' -;; * lisp/bbdb-ftp.el (bbdb-ftp): use `bbdb-get-record' -;; -;; Revision 1.57 2000/07/13 17:07:00 sds -;; minor doc fixes to comply with the standards -;; -;; Revision 1.56 2000/04/13 00:12:02 waider -;; * Thomas's duplicates patch -;; -;; Revision 1.55 1998/04/11 07:21:39 simmonmt -;; Colin Rafferty's patch adding autoload cookies back -;; -;; Revision 1.54 1998/02/23 07:00:18 simmonmt -;; Intro rewrite to say that EFS is also OK as a prereq -;; -;; Revision 1.53 1998/01/06 04:52:15 simmonmt -;; Customized variables (into utilities-ftp group). Added provide. -;; -;; Revision 1.52 1997/09/28 05:59:18 simmonmt -;; Added check for EFS (there must be a better way that what I did, but I -;; really don't want to be reduced to checking version strings. -;; ;;; This file adds the ability to define ftp-sites in a BBDB, much the same ;;; way one adds a regular person's name to the BBDB. It also defines the @@ -110,9 +84,9 @@ "Expands into an accessor function for slots in the notes alist." (let ((fn-name (intern (concat "bbdb-record-" (symbol-name slot))))) (list 'defun fn-name (list 'record) - (list 'cdr - (list 'assoc (list 'quote slot) - (list 'bbdb-record-raw-notes 'record)))))) + (list 'cdr + (list 'assoc (list 'quote slot) + (list 'bbdb-record-raw-notes 'record)))))) (defun-bbdb-raw-notes-accessor ftp-dir) (defun-bbdb-raw-notes-accessor ftp-user) @@ -120,23 +94,23 @@ (defun bbdb-record-ftp-site (record) "Acessor Function. Returns the ftp-site field of the BBDB record or nil." (let* ((name (bbdb-record-name record)) - (ftp-pfx-regexp (concat bbdb-ftp-site-name-designator-prefix " *")) - (ftp-site - (and (string-match ftp-pfx-regexp name) - (substring name (match-end 0))))) + (ftp-pfx-regexp (concat bbdb-ftp-site-name-designator-prefix " *")) + (ftp-site + (and (string-match ftp-pfx-regexp name) + (substring name (match-end 0))))) ftp-site)) (defun remove-leading-whitespace (string) "Remove any spaces or tabs from only the start of the string." (let ((space-char-code (string-to-char " ")) - (tab-char-code ?\t) - (index 0)) + (tab-char-code ?\t) + (index 0)) (if string - (progn - (while (or (char-equal (elt string index) space-char-code) - (char-equal (elt string index) tab-char-code)) - (setq index (+ index 1))) - (substring string index)) + (progn + (while (or (char-equal (elt string index) space-char-code) + (char-equal (elt string index) tab-char-code)) + (setq index (+ index 1))) + (substring string index)) nil))) ;;;###autoload @@ -175,31 +149,31 @@ collisions." (setq site (bbdb-read-string "Ftp Site: ")) (setq site (concat bbdb-ftp-site-name-designator-prefix site)) (if (and bbdb-no-duplicates-p - (bbdb-gethash (downcase site))) - (error "%s is already in the database" site)))) + (bbdb-gethash (downcase site))) + (error "%s is already in the database" site)))) (let* ((dir (bbdb-read-string "Ftp Directory: " - bbdb-default-ftp-dir)) - (user (bbdb-read-string "Ftp Username: " - bbdb-default-ftp-user)) - (company (bbdb-read-string "Company: ")) - (notes (bbdb-read-string "Additional Comments: ")) - (names (bbdb-divide-name site)) - (firstname (car names)) - (lastname (nth 1 names))) + bbdb-default-ftp-dir)) + (user (bbdb-read-string "Ftp Username: " + bbdb-default-ftp-user)) + (company (bbdb-read-string "Company: ")) + (notes (bbdb-read-string "Additional Comments: ")) + (names (bbdb-divide-name site)) + (firstname (car names)) + (lastname (nth 1 names))) (if (string= user bbdb-default-ftp-user) (setq user nil)) (if (string= company "") (setq company nil)) (if (or (string= dir bbdb-default-ftp-dir) (string= dir "")) - (setq dir nil)) + (setq dir nil)) (if (string= notes "") (setq notes nil)) (let ((record - (vector firstname lastname nil company nil nil nil - (append - (if notes (list (cons 'notes notes)) nil) - (if dir (list (cons 'ftp-dir dir)) nil) - (if user (list (cons 'ftp-user user)) nil)) - (make-vector bbdb-cache-length nil)))) - record)))) + (vector firstname lastname nil company nil nil nil + (append + (if notes (list (cons 'notes notes)) nil) + (if dir (list (cons 'ftp-dir dir)) nil) + (if user (list (cons 'ftp-user user)) nil)) + (make-vector bbdb-cache-length nil)))) + record)))) ;;;###autoload (defun bbdb-create-ftp-site (record) diff --git a/lisp/bbdb-gui.el b/lisp/bbdb-gui.el index 2598d32..69029c1 100644 --- a/lisp/bbdb-gui.el +++ b/lisp/bbdb-gui.el @@ -29,8 +29,18 @@ ;; compiler whinage. Some of this is legacy stuff that would probably ;; be better deleted. (defvar scrollbar-height nil) -(or (fboundp 'set-specifier) - (fset 'set-specifier 'ignore)) +(eval-when-compile + (or (fboundp 'set-specifier) + (fset 'set-specifier 'ignore)) + (or (fboundp 'make-glyph) + (fset 'make-glyph 'ignore)) + (or (fboundp 'set-glyph-face) + (fset 'set-glyph-face 'ignore)) + (or (fboundp 'highlight-headers-x-face) + (fset 'highlight-headers-x-face 'ignore)) + (or (fboundp 'highlight-headers-x-face-to-pixmap) + (fset 'highlight-headers-x-face-to-pixmap 'ignore))) + (if (string-match "XEmacs\\|Lucid" emacs-version) (progn @@ -82,7 +92,7 @@ (fset 'bbdb-delete-extent 'delete-overlay)) (if (fboundp 'mapcar-extents) - (defun bbdb-list-extents() (mapcar-extents 'identity)) + (defmacro bbdb-list-extents() `(mapcar-extents 'identity)) (defun bbdb-list-extents() (let ((o (overlay-lists))) (nconc (car o) (cdr o))))) diff --git a/lisp/bbdb-hooks.el b/lisp/bbdb-hooks.el index 86d7e7a..18f2579 100644 --- a/lisp/bbdb-hooks.el +++ b/lisp/bbdb-hooks.el @@ -36,17 +36,19 @@ ;; (require 'bbdb) +(require 'bbdb-com) + +(eval-when-compile + (condition-case() (require 'gnus) (error nil)) + (condition-case () (require 'vm) (error nil)) + (autoload 'mh-show "mh-e") + (require 'bbdb-vm) + (require 'bbdb-gnus) + (require 'bbdb-rmail)) (defvar rmail-buffer) (defvar mh-show-buffer) -(defmacro the-v18-byte-compiler-sucks-wet-farts-from-dead-pigeons () - ;; no such thing as eval-when, no way to conditionally require something - ;; at compile time (except this!! <evil laughter> ) - (condition-case () (require 'vm) (error nil)) - nil) -(defun Nukem-til-they-glow () - (the-v18-byte-compiler-sucks-wet-farts-from-dead-pigeons)) (defvar bbdb-time-internal-format "%Y-%m-%d" "The internal date format.") @@ -418,7 +420,7 @@ the variables `bbdb-auto-notes-alist' and `bbdb-auto-notes-ignore'." (setq ignore-all (cdr ignore-all)))) (unless ignore ; ignore-all matched - (while rest ; while their still are clauses in the auto-notes alist + (while rest ; while there are still clauses in the auto-notes alist (goto-char marker) (setq field (car (car rest)) ; name of header, e.g., "Subject" pairs (cdr (car rest)) ; (REGEXP . STRING) or @@ -427,7 +429,7 @@ the variables `bbdb-auto-notes-alist' and `bbdb-auto-notes-ignore'." fieldval (bbdb-extract-field-value field)) ; e.g., Subject line (when fieldval ;; we perform the auto notes stuff only for authors of a message - ;; or if explicitly requested + ;; or if explicitly requested (if (or (symbolp (caar pairs)) (listp (caar pairs))) (if (or (memq bbdb-update-address-class (car pairs)) (and (assoc bbdb-update-address-class (car pairs)) diff --git a/lisp/bbdb-snarf.el b/lisp/bbdb-snarf.el index 93a1651..23821e4 100644 --- a/lisp/bbdb-snarf.el +++ b/lisp/bbdb-snarf.el @@ -384,13 +384,15 @@ more details." new-record) ;;---------------------------------------------------------------------------- -;; Emacs 20.3 seems to miss the function replace-in-string? -(unless (fboundp 'replace-in-string) - (if (fboundp 'replace-regexp-in-string) ; defined in e21 - (defun replace-in-string (string regexp newtext &optional literal) - (replace-regexp-in-string regexp newtext string nil literal)) +(eval-and-compile + (if (fboundp 'replace-in-string) + (fset 'bbdb-replace-in-string 'replace-in-string) + (if (fboundp 'replace-regexp-in-string) ; defined in e21 + (fset 'bbdb-replace-regexp-in-string 'replace-regexp-in-string) ;; actually this is `dired-replace-in-string' slightly modified - (defun replace-in-string (string regexp newtext &optional literal) + ;; We're not defining the whole thing, just enough for our purposes. + (defun bbdb-replace-regexp-in-string (regexp newtext string &optional + fixedcase literal) ;; Replace REGEXP with NEWTEXT everywhere in STRING and return result. ;; NEWTEXT is taken literally---no \\DIGIT escapes will be recognized. (let ((result "") (start 0) mb me) @@ -399,7 +401,11 @@ more details." me (match-end 0) result (concat result (substring string start mb) newtext) start me)) - (concat result (substring string start)))))) + (concat result (substring string start))))) + (defun bbdb-replace-in-string (string regexp newtext &optional literal) + (bbdb-replace-regexp-in-string regexp newtext string nil literal)))) + + (defcustom bbdb-extract-address-components-func 'bbdb-extract-address-components @@ -493,9 +499,9 @@ If extracting fails one probably has to adjust the variable nomatch) ;; Do some string cleanup and trimming - (setq adstring (replace-in-string adstring "[\n\t]" " ")) - (setq adstring (replace-in-string adstring " " " ")) - (setq adstring (replace-in-string adstring "^ +" "")) + (setq adstring (bbdb-replace-in-string adstring "[\n\t]" " ")) + (setq adstring (bbdb-replace-in-string adstring " " " ")) + (setq adstring (bbdb-replace-in-string adstring "^ +" "")) ;; scan the string (while (not (string= "" adstring)) @@ -639,7 +645,7 @@ version doesn't support multiple addresses." (setq errors (1+ errors))) (setq test-cases (cdr test-cases)))) (setq extr-functions (cdr extr-functions))) - + (if (> errors 0) (error "There have been %d errors in bbdb-extract-address-components." errors) diff --git a/lisp/bbdb-w3.el b/lisp/bbdb-w3.el index 8f92ab2..fc02e2d 100644 --- a/lisp/bbdb-w3.el +++ b/lisp/bbdb-w3.el @@ -19,50 +19,14 @@ ;; ;; $Id$ ;; -;; $Log$ -;; Revision 1.8 2001/01/17 19:55:07 fenk -;; (bbdb-www-grab-homepage): -;; Fix to read just one record not a list of records -;; -;; Revision 1.7 2000/05/02 18:19:17 sds -;; * lisp/bbdb.el, lisp/bbdb-com.el: define `unless' and `when' if -;; necessary, do not quote `lambda' in code, do quote (`') functions -;; and variables in doc strings. -;; * lisp/bbdb.el (bbdb-get-field): new helper function. -;; * lisp/bbdb-com.el (bbdb-notes-sort-order): new variable -;; (bbdb-sort-notes, bbdb-sort-phones, bbdb-sort-addresses): new -;; functions, suitable for `bbdb-change-hook'. -;; (bbdb-get-record): new helper function. -;; * lisp/bbdb-w3.el (bbdb-www): do not browse to multiple URLs -;; simultaneously, allow multiple URLs for the same record instead. -;; (bbdb-www-grab-homepage): add the URL if there is such a fields -;; already. -;; -;; Revision 1.6 1998/04/11 07:06:30 simmonmt -;; Colin Rafferty's patch adding autoload cookies back -;; -;; Revision 1.5 1998/01/06 06:18:22 simmonmt -;; Removed autoloads and added provide for bbdb-w3 -;; -;; Revision 1.4 1997/10/26 05:03:49 simmonmt -;; Use browse-url-browser-function rather than a funcall -;; -;; Revision 1.3 1997/10/12 00:18:50 simmonmt -;; Added bbdb-insinuate-w3 to set keyboard map correctly. Merged -;; bbdb-www-netscape into bbdb-www using browse-url-browser-function to -;; differentiate. -;; -;; Revision 1.2 1997/10/11 20:21:32 simmonmt -;; Modifications mailed in by David Carlton <carlton@math.mit.edu>. They -;; look to be mostly adaptations for netscape -;; -;; Revision 1.1 1997/10/11 19:05:54 simmonmt -;; Initial revision -;; -;; +(require 'bbdb-com) (require 'browse-url) +(defvar w3-mode-map) +(eval-when-compile + (condition-case() (require 'url) (error (fset 'url-view-url 'ignore)))) + ;;;###autoload (defun bbdb-www (rec &optional which) "Visit URLs stored in the `www' field of the current record. @@ -94,6 +58,6 @@ Non-interactively, do all records if arg is nonnil." (defun bbdb-insinuate-w3 () "Call this function to hook BBDB into W3." (add-hook 'w3-mode-hook - (lambda () (define-key w3-mode-map ":" 'bbdb-www-grab-homepage)))) + (lambda () (define-key w3-mode-map ":" 'bbdb-www-grab-homepage)))) (provide 'bbdb-w3) diff --git a/lisp/bbdb.el b/lisp/bbdb.el index 2ae2172..8ffb451 100644 --- a/lisp/bbdb.el +++ b/lisp/bbdb.el @@ -1012,6 +1012,12 @@ If the note is absent, returns a zero length string." (list 'match-beginning match-number) (list 'match-end match-number)))) +(eval-and-compile + (if (fboundp 'display-error) + (fset 'bbdb-display-error 'display-error) + (defun bbdb-display-error(msg stream) + (message "Error: %s" (nth 1 msg))))) + (defmacro bbdb-error-retry (form) (list 'catch ''--bbdb-error-retry-- (list 'while ''t @@ -1020,9 +1026,7 @@ If the note is absent, returns a zero length string." '(error (ding) (let ((cursor-in-echo-area t)) - (if (fboundp 'display-error) ; lemacs 19.8+ - (display-error --c-- nil) - (message "Error: %s" (nth 1 --c--))) + (bbdb-display-error --c-- nil) (sit-for 2))))))) ;;; Completion on labels and field data |