From c327c4058fa792efb8c6d072dd74b35956941ee0 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sat, 18 Oct 2003 01:05:54 +0000 Subject: [PATCH] Rewrite one-armed `if' constructs using either `when' or `unless'. (hs-grok-mode-type): Elide superfluous `progn'; nfc. --- lisp/ChangeLog | 14 +++++-- lisp/progmodes/hideshow.el | 82 +++++++++++++++++++------------------- 2 files changed, 50 insertions(+), 46 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c395b3c2a31..e7160dc9cbd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2003-10-18 Thien-Thi Nguyen + + * progmodes/hideshow.el: Rewrite one-armed `if' + constructs using either `when' or `unless'. + (hs-grok-mode-type): Elide superfluous `progn'; nfc. + 2003-10-16 Nick Roberts * gdb-ui.el (breakpoint-xpm-data, breakpoint-enabled-pbm-data) @@ -37,22 +43,22 @@ (set-fringe-style): Ditto. 2003-10-12 Michael Kifer - + * ediff-mult.el (ediff-filegroup-action): Use ediff-default-filtering-regexp. - + * ediff-util.el (ediff-recenter): Don't call ediff-restore-highlighting twice. (ediff-select-difference): Set current difference. (ediff-unselect-and-select-difference): Added comment. - + * ediff.el (ediff-directories,ediff-directory-revisions) (ediff-directories3,ediff-merge-directories) (ediff-merge-directories-with-ancestor) (ediff-merge-directory-revisions) (ediff-merge-directory-revisions-with-ancestor): Use ediff-default-filtering-regexp. - + 2003-10-12 Andreas Schwab * international/mule-cmds.el (locale-charset-language-names): diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el index fbba8603b64..7013c3856e3 100644 --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el @@ -395,9 +395,9 @@ Note that `mode-line-format' is buffer-local.") ; (setq buffer-invisibility-spec ; (cons arg buffer-invisibility-spec))))) ; (defun remove-from-invisibility-spec (arg) -; (if buffer-invisibility-spec -; (setq buffer-invisibility-spec -; (delete arg buffer-invisibility-spec))))) +; (when buffer-invisibility-spec +; (setq buffer-invisibility-spec +; (delete arg buffer-invisibility-spec))))) ;; hs-match-data (defalias 'hs-match-data 'match-data) @@ -497,29 +497,29 @@ The block beginning is adjusted by `hs-adjust-block-beginning' and then further adjusted to be at the end of the line." (if comment-reg (hs-hide-comment-region (car comment-reg) (cadr comment-reg) end) - (if (looking-at hs-block-start-regexp) - (let* ((mdata (hs-match-data t)) - (pure-p (match-end 0)) - (p - ;; `p' is the point at the end of the block beginning, - ;; which may need to be adjusted - (save-excursion - (goto-char (funcall (or hs-adjust-block-beginning - 'identity) - pure-p)) - ;; whatever the adjustment, we move to eol - (end-of-line) - (point))) - (q - ;; `q' is the point at the end of the block - (progn (hs-forward-sexp mdata 1) - (end-of-line) - (point)))) - (if (and (< p (point)) (> (count-lines p q) 1)) - (overlay-put (hs-flag-region p q 'code) - 'hs-ofs - (- pure-p p))) - (goto-char (if end q (min p pure-p))))))) + (when (looking-at hs-block-start-regexp) + (let* ((mdata (hs-match-data t)) + (pure-p (match-end 0)) + (p + ;; `p' is the point at the end of the block beginning, + ;; which may need to be adjusted + (save-excursion + (goto-char (funcall (or hs-adjust-block-beginning + 'identity) + pure-p)) + ;; whatever the adjustment, we move to eol + (end-of-line) + (point))) + (q + ;; `q' is the point at the end of the block + (progn (hs-forward-sexp mdata 1) + (end-of-line) + (point)))) + (when (and (< p (point)) (> (count-lines p q) 1)) + (overlay-put (hs-flag-region p q 'code) + 'hs-ofs + (- pure-p p))) + (goto-char (if end q (min p pure-p))))))) (defun hs-safety-is-job-n () "Warn if `buffer-invisibility-spec' does not contain symbol `hs'." @@ -568,16 +568,16 @@ as cdr." (setq p (point));; use this to avoid an infinite cycle (forward-comment 1) (skip-chars-forward " \t\n\f")) - (if (or (not (looking-at hs-c-start-regexp)) - (> (point) q)) - ;; we cannot hide this comment block - (setq not-hidable t))) + (when (or (not (looking-at hs-c-start-regexp)) + (> (point) q)) + ;; we cannot hide this comment block + (setq not-hidable t))) ;; goto the end of the comment (forward-comment (buffer-size)) (skip-chars-backward " \t\n\f") (end-of-line) - (if (>= (point) q) - (list (if not-hidable nil p) (point)))))))) + (when (>= (point) q) + (list (if not-hidable nil p) (point)))))))) (defun hs-grok-mode-type () "Set up hideshow variables for new buffers. @@ -607,9 +607,8 @@ function; and adjust-block-beginning function." c-start-regexp))) hs-forward-sexp-func (or (nth 4 lookup) 'forward-sexp) hs-adjust-block-beginning (nth 5 lookup))) - (progn - (setq hs-minor-mode nil) - (error "%s Mode doesn't support Hideshow Minor Mode" mode-name)))) + (setq hs-minor-mode nil) + (error "%s Mode doesn't support Hideshow Minor Mode" mode-name))) (defun hs-find-block-beginning () "Reposition point at block-start. @@ -667,11 +666,11 @@ and `case-fold-search' are both t." (if (and c-reg (nth 0 c-reg)) ;; point is inside a comment, and that comment is hidable (goto-char (nth 0 c-reg)) - (if (and (not c-reg) - (hs-find-block-beginning) - (looking-at hs-block-start-regexp)) - ;; point is inside a block - (goto-char (match-end 0))))) + (when (and (not c-reg) + (hs-find-block-beginning) + (looking-at hs-block-start-regexp)) + ;; point is inside a block + (goto-char (match-end 0))))) (end-of-line) (let ((overlays (overlays-at (point))) (found nil)) @@ -888,8 +887,7 @@ Key bindings: ;; load-time actions ;; keymaps and menus -(if hs-minor-mode-map - nil +(unless hs-minor-mode-map (setq hs-minor-mode-map (make-sparse-keymap)) (easy-menu-define hs-minor-mode-menu hs-minor-mode-map -- 2.39.2