diff options
Diffstat (limited to 'kotl/kvspec.el')
| -rw-r--r-- | kotl/kvspec.el | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/kotl/kvspec.el b/kotl/kvspec.el index 9e0ee89..d6c111d 100644 --- a/kotl/kvspec.el +++ b/kotl/kvspec.el @@ -1,4 +1,4 @@ -;;; kvspec.el --- Koutline view specification +;;; kvspec.el --- Koutline view specification -*- lexical-binding:t -*- ;; ;; Author: Bob Weiner ;; @@ -11,7 +11,7 @@ ;;; Commentary: ;; -;;; Koutliner view specs (each viewspec is invoked with its first letter) +;; Koutliner view specs (each viewspec is invoked with its first letter) ;; + means support code has been written already. ;; ;; + all: Show all lines of cells and all cells in the outline. @@ -53,11 +53,10 @@ ;;; ************************************************************************ (require 'kview) +(require 'outline) ;For outline-flag-region. +(require 'kproperty) ;; Quiet byte compiler warnings for these free variables. -(eval-when-compile - (defvar label-sep-len nil) - (defvar modeline-format nil)) ;;; ************************************************************************ ;;; Public variables @@ -89,6 +88,9 @@ VIEW-SPEC is a string or t, which means recompute the current view spec. See (make-local-variable 'kvspec:current) (make-local-variable 'kvspec:string))) +(declare-function kotl-mode:hide-subtree "kotl-mode" + (&optional cell-ref show-flag)) + (defun kvspec:levels-to-show (levels-to-keep) "Hide all cells in outline at levels deeper than LEVELS-TO-KEEP (a number). Shows any hidden cells within LEVELS-TO-KEEP. 1 is the first level. 0 means @@ -99,9 +101,9 @@ display all levels of cells." nil nil t))) (setq levels-to-keep (prefix-numeric-value levels-to-keep)) (if (< levels-to-keep 0) - (error "(kvspec:levels-to-show): Must display at least one level.")) + (error "(kvspec:levels-to-show): Must display at least one level")) (kview:map-tree - (lambda (kview) + (lambda (_kview) (if (/= (kcell-view:level) levels-to-keep) (kotl-mode:show-tree) (kotl-mode:hide-subtree) @@ -119,9 +121,10 @@ display all levels of cells." (error "(kvspec:show-lines-per-cell): Invalid lines per cell, `%d'" num)) (kview:set-attr kview 'lines-to-show num) ;; Now show NUM lines in cells. - (kview:map-tree (lambda (kview) + (kview:map-tree (lambda (_kview) (kcell-view:expand (point)) - (kvspec:show-lines-this-cell num)) kview t t)) + (kvspec:show-lines-this-cell num)) + kview t t)) (defun kvspec:toggle-blank-lines () "Toggle blank lines between cells on or off." @@ -158,6 +161,30 @@ view specs." (kvspec:update-modeline)) ;;; ************************************************************************ +;;; Private variables +;;; ************************************************************************ + +(defconst kvspec:label-type-alist + '((?0 . id) + (?1 . alpha) + (?. . legal) + ;; (?2 . partial-alpha) + ;; (?* . star) + ;; (?~ . no) + ) + "Alist of (view-spec-character . label-type) pairs.") + +(defvar kvspec:string "" + "String displayed in koutline modelines to reflect the current view spec. +It is local to each koutline. Set this to nil to disable modeline display of +the view spec settings.") + +(defvar kvspec:string-format " <|%s>" + "Format of the kview spec modeline display. +It must contain a `%s' which is replaced with the current set of view spec +characters at run-time.") + +;;; ************************************************************************ ;;; Private functions ;;; ************************************************************************ @@ -261,8 +288,9 @@ view specs." 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. (unless (< num 1) - (let ((start (goto-char (kcell-view:start (point) label-sep-len))) - (end (kcell-view:end-contents))) + (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))))) @@ -324,30 +352,6 @@ If NUM is less than 1 or greater than the number of lines available, the cell re ) (set-buffer-modified-p modified-p))) -;;; ************************************************************************ -;;; Private variables -;;; ************************************************************************ - -(defconst kvspec:label-type-alist - '((?0 . id) - (?1 . alpha) - (?. . legal) - ;; (?2 . partial-alpha) - ;; (?* . star) - ;; (?~ . no) - ) - "Alist of (view-spec-character . label-type) pairs.") - -(defvar kvspec:string "" - "String displayed in koutline modelines to reflect the current view spec. -It is local to each koutline. Set this to nil to disable modeline display of -the view spec settings.") - -(defvar kvspec:string-format " <|%s>" - "Format of the kview spec modeline display. -It must contain a `%s' which is replaced with the current set of view spec -characters at run-time.") - (provide 'kvspec) ;;; kvspec.el ends here |
