diff options
| author | Stefan Monnier <monnier@iro.umontreal.ca> | 2019-08-14 04:29:57 -0400 |
|---|---|---|
| committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2019-08-14 04:29:57 -0400 |
| commit | 6e555e763567c66ad8e50724a7dd5e286dbb1e65 (patch) | |
| tree | 86fb29daa274d8007063babec826719154bf087e /kotl/kvspec.el | |
| parent | 98a5ecb3bf80f2b53523c769459d1a1a49491125 (diff) | |
| parent | 332ef336a7ad87e25c0563bfeaf0e6758d52c59c (diff) | |
Merge remote-tracking branch 'hyperbole/master' into externals/hyperbolescratch/hyperbole-lexbind
Diffstat (limited to 'kotl/kvspec.el')
| -rw-r--r-- | kotl/kvspec.el | 79 |
1 files changed, 29 insertions, 50 deletions
diff --git a/kotl/kvspec.el b/kotl/kvspec.el index a9e5354..d6c111d 100644 --- a/kotl/kvspec.el +++ b/kotl/kvspec.el @@ -4,7 +4,7 @@ ;; ;; Orig-Date: 21-Oct-95 at 15:17:07 ;; -;; Copyright (C) 1995-2017 Free Software Foundation, Inc. +;; Copyright (C) 1995-2019 Free Software Foundation, Inc. ;; See the "../HY-COPY" file for license information. ;; ;; This file is part of GNU Hyperbole. @@ -116,16 +116,15 @@ display all levels of cells." (kview:set-attr kview 'levels-to-show levels-to-keep)) (defun kvspec:show-lines-per-cell (num) - "Show NUM lines per cell." + "Show NUM lines per visible cell; 0 means show all lines in each visible cell." (if (or (not (integerp num)) (< num 0)) (error "(kvspec:show-lines-per-cell): Invalid lines per cell, `%d'" num)) (kview:set-attr kview 'lines-to-show num) - (if (not (zerop num)) - ;; Now show NUM lines in cells. - (kview:map-tree (lambda (_kview) - (kcell-view:expand (point)) - (kvspec:show-lines-this-cell num)) - kview t t))) + ;; Now show NUM lines in cells. + (kview:map-tree (lambda (_kview) + (kcell-view:expand (point)) + (kvspec:show-lines-this-cell num)) + kview t t)) (defun kvspec:toggle-blank-lines () "Toggle blank lines between cells on or off." @@ -251,32 +250,25 @@ characters at run-time.") ;; "l" means use value of kview:default-levels-to-show. ;; "l0" means show all levels. (let (levels) - (if (not (string-match "l\\([0-9]+\\)?" kvspec:current)) - ;; Don't change the view if no view spec is given but note that - ;; all levels should be shown in the future. - (kview:set-attr kview 'levels-to-show 0) - (if (match-beginning 1) - (setq levels (string-to-number (match-string 1 kvspec:current))) - (setq levels kview:default-levels-to-show)) - (kvspec:levels-to-show levels)))) + (if (and (string-match "l\\([0-9]+\\)?" kvspec:current) + (match-beginning 1)) + (setq levels (string-to-number (match-string 1 kvspec:current))) + (setq levels kview:default-levels-to-show)) + (kvspec:levels-to-show levels))) (defun kvspec:lines-to-show () "Show a set number of lines per cell according to `kvspec:current'." - ;; "c" means use value of kview:default-lines-to-show. + ;; "c" or no "c" means use value of kview:default-lines-to-show. ;; "c0" means show all lines. - (cond ((not (string-match "c\\([0-9]+\\)?" kvspec:current)) - ;; Don't change the view if no view spec is given but note that all - ;; lines should be shown in the future. - (kview:set-attr kview 'lines-to-show 0)) - ((match-beginning 1) - (kvspec:show-lines-per-cell - (string-to-number (match-string 1 kvspec:current)))) - (t (kvspec:show-lines-per-cell kview:default-lines-to-show)))) + (if (and (string-match "c\\([0-9]+\\)?" kvspec:current) + (match-beginning 1)) + (kvspec:show-lines-per-cell + (string-to-number (match-string 1 kvspec:current))) + (kvspec:show-lines-per-cell kview:default-lines-to-show))) (defun kvspec:numbering () "Set the type of numbering (label) display according to `kvspec:current'." - (if (not (string-match "n\\([.*~0-2]\\)?" kvspec:current)) - nil + (when (string-match "n\\([.*~0-2]\\)?" kvspec:current) ;; "n" means use value of kview:default-label-type. ;; "n0" means display idstamps. ;; "n1" means display alpha labels. @@ -286,23 +278,22 @@ characters at run-time.") ;; "n~" means no labels. (let (spec type) (if (match-beginning 1) - (setq spec (string-to-char - (substring kvspec:current - (match-beginning 1) (match-end 1))) + (setq spec (string-to-char (match-string 1 kvspec:current)) type (cdr (assq spec kvspec:label-type-alist))) (setq type kview:default-label-type)) (kview:set-label-type kview type)))) (defun kvspec:show-lines-this-cell (num) "Assume the current cell is fully expanded and collapse to show NUM lines within it. -If NUM is greater than the number of lines available, the cell remains fully expanded." +If NUM is less than 1 or greater than the number of lines available, the cell remains fully expanded." ;; Use free variable label-sep-len bound in kview:map-* for speed. - (defvar label-sep-len) - (goto-char (kcell-view:start (point) label-sep-len)) - (let ((end (kcell-view:end-contents))) - ;; Hide all but num lines of the cell. - (and (> num 0) (search-forward "\n" end t num) - (outline-flag-region (1- (point)) end t)))) + (unless (< num 1) + (defvar label-sep-len) + (goto-char (kcell-view:start (point) label-sep-len)) + (let ((end (kcell-view:end-contents))) + ;; Hide all but num lines of the cell. + (and (search-forward "\n" end t num) + (outline-flag-region (1- (point)) end t))))) (defun kvspec:update-modeline () "Setup or update display of the current kview spec in the modeline." @@ -315,19 +306,7 @@ If NUM is greater than the number of lines available, the cell remains fully exp (memq 'modeline-buffer-identification mode-line-format)))) (if elt - (setcdr elt (cons 'kvspec:string (cdr elt))) - ;; - ;; XEmacs 19.14 introduced extents into the modeline that we - ;; must work around. Assume any XEmacs is at least that new. - (if (featurep 'xemacs) - (let ((mf modeline-format) - elt) - (while mf - (setq elt (car mf)) - (if (and (consp elt) (eq (cdr elt) 'modeline-buffer-identification)) - (progn (setcdr mf (cons 'kvspec:string (cdr mf))) - (setq mf nil))) - (setq mf (cdr mf))))))))) + (setcdr elt (cons 'kvspec:string (cdr elt))))))) (defun kvspec:update-view () "Update view according to current setting of local `kvspec:current' variable." |
