Mercurial > emacs
changeset 45769:2030da0c85f2
Use `when', `unless'.
(calc-trail-mode): Use an italic `font-lock-face'.
(calc-refresh): Ditto.
author | Colin Walters <walters@gnu.org> |
---|---|
date | Wed, 12 Jun 2002 05:11:22 +0000 |
parents | 0cb70c7f8851 |
children | 159963013ec6 |
files | lisp/calc/calc.el |
diffstat | 1 files changed, 91 insertions(+), 102 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/calc/calc.el Wed Jun 12 05:10:38 2002 +0000 +++ b/lisp/calc/calc.el Wed Jun 12 05:11:22 2002 +0000 @@ -680,13 +680,13 @@ (while (and p2 (not (file-exists-p (expand-file-name name2 (car p2))))) (setq p2 (cdr p2))) - (if p2 - (setq load-path (nconc load-path - (list - (directory-file-name - (file-name-directory - (expand-file-name - name (car p2)))))))))) + (when p2 + (setq load-path (nconc load-path + (list + (directory-file-name + (file-name-directory + (expand-file-name + name (car p2)))))))))) ;; If calc-autoload-directory is given, use that (and hope it works!). (and calc-autoload-directory @@ -867,10 +867,10 @@ (mapcar (function (lambda (x) (define-key calc-dispatch-map (char-to-string (car x)) (cdr x)) - (if (string-match "abcdefhijklnopqrstuwxyz" - (char-to-string (car x))) - (define-key calc-dispatch-map - (char-to-string (- (car x) ?a -1)) (cdr x))) + (when (string-match "abcdefhijklnopqrstuwxyz" + (char-to-string (car x))) + (define-key calc-dispatch-map + (char-to-string (- (car x) ?a -1)) (cdr x))) (define-key calc-dispatch-map (format "\e%c" (car x)) (cdr x)))) '( ( ?a . calc-embedded-activate ) ( ?b . calc-big-or-small ) @@ -961,15 +961,14 @@ (sit-for echo-keystrokes) (condition-case err ; look for other keys bound to calc-dispatch (let ((keys (this-command-keys))) - (or (not (stringp keys)) - (string-match "\\`\C-u\\|\\`\e[-0-9#]\\|`[\M--\M-0-\M-9]" keys) - (eq (lookup-key calc-dispatch-map keys) 'calc-same-interface) - (progn - (and (string-match "\\`[\C-@-\C-_]" keys) - (symbolp - (lookup-key calc-dispatch-map (substring keys 0 1))) - (define-key calc-dispatch-map (substring keys 0 1) nil)) - (define-key calc-dispatch-map keys 'calc-same-interface)))) + (unless (or (not (stringp keys)) + (string-match "\\`\C-u\\|\\`\e[-0-9#]\\|`[\M--\M-0-\M-9]" keys) + (eq (lookup-key calc-dispatch-map keys) 'calc-same-interface)) + (when (and (string-match "\\`[\C-@-\C-_]" keys) + (symbolp + (lookup-key calc-dispatch-map (substring keys 0 1)))) + (define-key calc-dispatch-map (substring keys 0 1) nil)) + (define-key calc-dispatch-map keys 'calc-same-interface))) (error nil)) (calc-do-dispatch arg)) @@ -1079,14 +1078,13 @@ (calc-refresh t) (calc-set-mode-line) ;; The calc-defs variable is a relic. Use calc-define properties instead. - (if (and (boundp 'calc-defs) - calc-defs) - (progn - (message "Evaluating calc-defs...") - (calc-need-macros) - (eval (cons 'progn calc-defs)) - (setq calc-defs nil) - (calc-set-mode-line))) + (when (and (boundp 'calc-defs) + calc-defs) + (message "Evaluating calc-defs...") + (calc-need-macros) + (eval (cons 'progn calc-defs)) + (setq calc-defs nil) + (calc-set-mode-line)) (calc-check-defines)) (defvar calc-check-defines 'calc-check-defines) ; suitable for run-hooks @@ -1127,13 +1125,15 @@ (setq buffer-read-only t) (make-local-variable 'overlay-arrow-position) (make-local-variable 'overlay-arrow-string) - (if buf - (progn - (make-local-variable 'calc-main-buffer) - (setq calc-main-buffer buf))) - (if (= (buffer-size) 0) - (let ((buffer-read-only nil)) - (insert "Emacs Calculator v" calc-version " by Dave Gillespie\n"))) + (set (make-local-variable 'font-lock-defaults) + '(nil t nil nil nil (font-lock-core-only . t))) + (when buf + (set (make-local-variable 'calc-main-buffer) buf)) + (when (= (buffer-size) 0) + (let ((buffer-read-only nil)) + (insert (propertize (concat "Emacs Calculator v" calc-version + " by Dave Gillespie\n") + 'font-lock-face 'italic)))) (run-hooks 'calc-trail-mode-hook)) (defun calc-create-buffer () @@ -1141,29 +1141,26 @@ (or (eq major-mode 'calc-mode) (calc-mode)) (setq max-lisp-eval-depth (max max-lisp-eval-depth 1000)) - (if calc-always-load-extensions - (calc-extensions)) - (if calc-language - (progn - (calc-extensions) - (calc-set-language calc-language calc-language-option t)))) + (when calc-always-load-extensions + (calc-extensions)) + (when calc-language + (calc-extensions) + (calc-set-language calc-language calc-language-option t))) ;;;###autoload (defun calc (&optional arg full-display interactive) "The Emacs Calculator. Full documentation is listed under \"calc-mode\"." (interactive "P") (if arg - (or (eq arg 0) - (progn - (calc-extensions) - (if (= (prefix-numeric-value arg) -1) - (calc-grab-region (region-beginning) (region-end) nil) - (if (= (prefix-numeric-value arg) -2) - (calc-keypad))))) - (if (get-buffer-window "*Calc Keypad*") - (progn - (calc-keypad) - (set-buffer (window-buffer (selected-window))))) + (unless (eq arg 0) + (calc-extensions) + (if (= (prefix-numeric-value arg) -1) + (calc-grab-region (region-beginning) (region-end) nil) + (when (= (prefix-numeric-value arg) -2) + (calc-keypad)))) + (when (get-buffer-window "*Calc Keypad*") + (calc-keypad) + (set-buffer (window-buffer (selected-window)))) (if (eq major-mode 'calc-mode) (calc-quit) (let ((oldbuf (current-buffer))) @@ -1199,11 +1196,10 @@ (window-point full-display) (select-window full-display)) (calc-check-defines) - (and calc-said-hello - (or (interactive-p) interactive) - (progn - (sit-for 2) - (message ""))) + (when (and calc-said-hello + (or (interactive-p) interactive)) + (sit-for 2) + (message "")) (setq calc-said-hello t))))) ;;;###autoload @@ -1707,7 +1703,8 @@ calc-any-evaltos nil) (erase-buffer) (when calc-show-banner - (insert "--- Emacs Calculator Mode ---\n")) + (insert (propertize "--- Emacs Calculator Mode ---\n" + 'font-lock-face 'italic))) (while thing (goto-char (point-min)) (when calc-show-banner @@ -2977,7 +2974,7 @@ (c (cond ((null a) "<nil>") ((eq calc-display-raw t) (format "%s" a)) ((stringp a) a) - ((eq a 'top-of-stack) ".") + ((eq a 'top-of-stack) (propertize "." 'font-lock-face 'bold)) (calc-prepared-composition calc-prepared-composition) ((and (Math-scalarp a) @@ -2991,41 +2988,39 @@ (and math-comp-selected (setq calc-any-selections t)) (setq w (cdr off) off (car off)) - (if (> off 0) - (setq c (math-comp-concat (make-string off ? ) c))) + (when (> off 0) + (setq c (math-comp-concat (make-string off ? ) c))) (or (equal calc-left-label "") (setq c (math-comp-concat (if (eq a 'top-of-stack) (make-string (length calc-left-label) ? ) calc-left-label) c))) - (if calc-line-numbering - (setq c (math-comp-concat (if (eq calc-language 'big) - (if math-comp-selected - '(tag t "1: ") "1: ") - " ") - c))) - (or (equal calc-right-label "") - (eq a 'top-of-stack) - (progn - (calc-extensions) - (setq c (list 'horiz c - (make-string (max (- w (math-comp-width c) - (length calc-right-label)) 0) ? ) - '(break -1) - calc-right-label)))) + (when calc-line-numbering + (setq c (math-comp-concat (if (eq calc-language 'big) + (when math-comp-selected + '(tag t "1: ") "1: ") + " ") + c))) + (unless (or (equal calc-right-label "") + (eq a 'top-of-stack)) + (calc-extensions) + (setq c (list 'horiz c + (make-string (max (- w (math-comp-width c) + (length calc-right-label)) 0) ? ) + '(break -1) + calc-right-label))) (setq s (if (stringp c) (if calc-display-raw (prin1-to-string c) c) (math-composition-to-string c w))) - (if calc-language-output-filter - (setq s (funcall calc-language-output-filter s))) + (when calc-language-output-filter + (setq s (funcall calc-language-output-filter s))) (if (eq calc-language 'big) (setq s (concat s "\n")) - (if calc-line-numbering - (progn - (aset s 0 ?1) - (aset s 1 ?:)))) + (when calc-line-numbering + (aset s 0 ?1) + (aset s 1 ?:))) (setcar (cdr entry) (calc-count-lines s)) s)) @@ -3038,8 +3033,8 @@ (calc-extensions) (math-stack-value-offset-fancy)) (setq off (or calc-display-origin 0)) - (if (integerp calc-line-breaking) - (setq wid calc-line-breaking))) + (when (integerp calc-line-breaking) + (setq wid calc-line-breaking))) (cons (max (- off (length calc-left-label)) 0) (+ wid num)))) @@ -3154,13 +3149,13 @@ (when calc-group-digits (require 'calc-ext) (setq str (math-group-float str)))) - (if (< figs 0) - (setq figs (+ calc-internal-prec figs))) - (if (> figs 0) - (let ((adj (- figs (math-numdigs mant)))) - (if (< adj 0) - (setq mant (math-scale-rounding mant adj) - exp (- exp adj))))) + (when (< figs 0) + (setq figs (+ calc-internal-prec figs))) + (when (> figs 0) + (let ((adj (- figs (math-numdigs mant)))) + (when (< adj 0) + (setq mant (math-scale-rounding mant adj) + exp (- exp adj))))) (setq str (if (integerp mant) (int-to-string mant) (math-format-bignum-decimal (cdr mant)))) @@ -3400,16 +3395,12 @@ (interactive "P") (calc-do-embedded-activate arg cbuf)) - (defun calc-user-invocation () (interactive) - (or (stringp calc-invocation-macro) - (error "Use `Z I' inside Calc to define a `M-# Z' keyboard macro")) + (unless (stringp calc-invocation-macro) + (error "Use `Z I' inside Calc to define a `M-# Z' keyboard macro")) (execute-kbd-macro calc-invocation-macro nil)) - - - ;;; User-programmability. ;;;###autoload @@ -3417,7 +3408,6 @@ (calc-extensions) (math-do-defmath func args body)) - ;;; Functions needed for Lucid Emacs support. (defun calc-read-key (&optional optkey) @@ -3445,10 +3435,9 @@ (calc-emacs-type-lucid (setq unread-command-event nil)) (setq unread-command-events nil))) -(if calc-always-load-extensions - (progn - (calc-extensions) - (calc-load-everything))) +(when calc-always-load-extensions + (calc-extensions) + (calc-load-everything)) (run-hooks 'calc-load-hook)