(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
(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 )
(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))
(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
(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 ()
(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)))
(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
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
(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)
(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))
(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))))
(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))))
(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
(calc-extensions)
(math-do-defmath func args body))
-
;;; Functions needed for Lucid Emacs support.
(defun calc-read-key (&optional optkey)
(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)