Function: kview:set-label-separator

kview:set-label-separator is an interactive and byte-compiled function defined in kview.el.

Signature

(kview:set-label-separator LABEL-SEPARATOR &optional SET-DEFAULT-P)

Documentation

Set the LABEL-SEPARATOR between labels and cell contents for the current kview.

The LABEL-SEPARATOR is a string. With optional prefix arg SET-DEFAULT-P, the default separator value used for new outlines is also set to this new value.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kview.el
(defun kview:set-label-separator (label-separator &optional set-default-p)
  "Set the LABEL-SEPARATOR between labels and cell contents for the current kview.
The LABEL-SEPARATOR is a string.
With optional prefix arg SET-DEFAULT-P, the default separator value used for
new outlines is also set to this new value."
  (interactive
   (progn (barf-if-buffer-read-only)
	  (list (if (kview:is-p kotl-kview)
		    (read-string
		     (format
		      "Change current%s label separator from \"%s\" to: "
		      (if current-prefix-arg " and default" "")
		      (kview:label-separator kotl-kview))))
		current-prefix-arg)))

  (barf-if-buffer-read-only)
  (cond ((not (kview:is-p kotl-kview))
	 (error "(kview:set-label-separator): This is not a koutline"))
	((not (stringp label-separator))
	 (error "(kview:set-label-separator): Invalid separator, \"%s\""
		label-separator))
	((< (length label-separator) 2)
	 (error "(kview:set-label-separator): Separator must be two or more characters, \"%s\""
		label-separator)))

  (let* ((old-sep-len (kview:label-separator-length kotl-kview))
	 (sep-len (length label-separator))
	 (sep-len-increase (- sep-len old-sep-len))
	 (indent)
	 (reindent-function
	  (cond ((zerop sep-len-increase)
		 (lambda ()))
		((> sep-len-increase 0)
		 ;; Increase indent in each cell line.
		 (lambda ()
		   (goto-char (point-min))
		   (setq indent (make-string
				 sep-len-increase ?\ ))
		   (while (re-search-forward "[^\n\r][\n\r] " nil t)
		     (insert indent))))
		(t
		 ;; Decrease indent in each cell line.
		 (lambda ()
		   (goto-char (point-min))
		   (setq indent
			 (concat "[^\n\r][\n\r]"
				 (make-string
				  (- sep-len-increase) ?\ )))
		   (while (re-search-forward indent nil t)
		     (delete-region
		      (+ (match-beginning 0) 2) (match-end 0))))))))
    (save-excursion
      (goto-char (point-min))
      (kproperty:replace-separator label-separator old-sep-len)
      ;; Reindent all lines in cells except the first line which has already
      ;; been done.
      (funcall reindent-function))
    (kview:set-attr kotl-kview 'label-separator label-separator)
    (kview:set-attr kotl-kview 'label-separator-length sep-len)
    (when set-default-p
      (setq kview:default-label-separator label-separator))))