Function: kotl-mode

kotl-mode is an autoloaded, interactive and byte-compiled function defined in kotl-mode.el.

Signature

(kotl-mode)

Documentation

The major mode used to edit and view koutlines.

Automatically invoked on files with a .kotl or .kot suffix.

It provides the following keys: Keymap kotl-mode-map is not currently defined.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kotl-mode.el
;;;###autoload
(defun kotl-mode ()
  "The major mode used to edit and view koutlines.
Automatically invoked on files with a .kotl or .kot suffix.

It provides the following keys:
\\{kotl-mode-map}"
  (interactive)
  (mapc #'make-local-variable
	'(hyrolo-entry-regexp
	  hyrolo-hdr-and-entry-regexp
	  hyrolo-entry-group-number
	  hyrolo-entry-trailing-space-group-number
	  indent-line-function
	  indent-region-function
	  kotl-previous-mode
	  line-move-ignore-invisible
	  minor-mode-alist
	  minor-mode-overriding-map-alist
	  outline-isearch-open-invisible-function
	  outline-level
	  outline-regexp
	  paragraph-separate
	  paragraph-start
	  selective-display-ellipses))
  ;; Enable Org Table editing minor mode so that necessary key binding
  ;; overrides are made.  If not desired, the user can disable it via
  ;; `kotl-mode-hook'.
  (orgtbl-mode 1)
  (unless kotl-mode-map
    (kotl-mode:setup-keymap))
  (unless kotl-mode-overriding-orgtbl-mode-map
    (kotl-mode:setup-overriding-orgtbl-keymap))
  (use-local-map kotl-mode-map)
  (set-syntax-table text-mode-syntax-table)
  ;; Turn off filladapt minor mode if on, so that it does not interfere with
  ;; the filling code in "kfill.el".
  (when (and (fboundp 'filladapt-mode) (boundp 'filladapt-mode) filladapt-mode)
    (filladapt-mode 0))
  (if (/= 3 (length (action:params (symbol-function 'fill-paragraph))))
      ;; Some package such as filladapt has overwritten the primitives
      ;; defined in kfill.el, so reload it.
      (load "kfill"))
  (setq-local fill-paragraph-function #'kfill:fill-paragraph)
  ;;
  ;; Prevent insertion of characters outside of editable bounds,
  ;; e.g. after the mouse sets point to a non-editable position.  Add hook
  ;; only in this major mode.
  (add-hook 'pre-command-hook #'kotl-mode:pre-self-insert-command nil t)
  ;;
  ;; Ensure that outline structure data is saved when save-buffer is called
  ;; from save-some-buffers, {C-x s}.
  (add-hook 'write-file-functions #'kotl-mode:update-buffer nil 'local)
  ;; Used by kimport.el functions.
  (unless (and (boundp 'kotl-previous-mode) kotl-previous-mode
	       (eq kotl-previous-mode #'kotl-mode)
	       (not (string-prefix-p hyrolo-display-buffer (buffer-name))))
    (setq hyrolo-entry-regexp (concat "^" kview:outline-regexp)
	  hyrolo-hdr-and-entry-regexp (concat hyrolo-hdr-prefix-regexp hyrolo-entry-regexp)
	  hyrolo-entry-group-number 2
	  hyrolo-entry-trailing-space-group-number 3

	  kotl-previous-mode major-mode
	  ;; Override orgtbl-mode keys with kotl-mode-specific ones.
	  minor-mode-overriding-map-alist (list (cons 'orgtbl-mode
						      kotl-mode-overriding-orgtbl-mode-map))
	  ;; Remove outline minor-mode mode-line indication.
	  minor-mode-alist (set:remove '(outline-minor-mode " Outl")
						      minor-mode-alist)
          minor-mode-alist (set:remove '(selective-display " Outline")
						      minor-mode-alist)
	  minor-mode-alist (set:remove '(selective-display " Otl")
						      minor-mode-alist)
	  ;; Remove indication that buffer is narrowed.
	  mode-line-format (copy-sequence mode-line-format)
	  mode-line-format (set:remove "%n" mode-line-format)
	  outline-level  #'hyrolo-outline-level
	  outline-regexp hyrolo-hdr-and-entry-regexp))
  ;;
  (hypb:add-to-invisibility-spec '(outline . t))
  (setq indent-line-function 'kotl-mode:indent-line
	indent-region-function 'kotl-mode:indent-region
	outline-isearch-open-invisible-function 'kotl-mode:isearch-open-invisible
	line-move-ignore-invisible 'keep-column
	local-abbrev-table text-mode-abbrev-table
	;; These par* settings must be anchored to the bol since
	;; kfill.el and `kotl-mode:fill-paragraph' use them in regexp
	;; searches.
	paragraph-separate "^[ \t]*$\\|^\^L"
	paragraph-start "^[ \t]*$\\|^\^L"
	selective-display nil
	selective-display-ellipses t
	track-eol t)
  ;;
  ;; This major-mode setting must come after the local variable settings but
  ;; before the koutline is formatted.
  (setq major-mode 'kotl-mode
	mode-name "Kotl"
	;; Used when indenting cells.
	indent-tabs-mode nil)

  ;; Used when indenting lines within cells.
  (make-local-variable 'kotl-mode:indent-tabs-mode)

  (setq auto-fill-function 'kfill:do-auto-fill)

  ;; May be a portion of a Koutline in a HyRolo match buffer; we set
  ;; kotl-mode then to use its local variable settings but don't want
  ;; to do any of the following formatting.
  (if (string-prefix-p hyrolo-display-buffer (buffer-name))
      (unless (and (boundp 'kotl-kview) (kview:is-p kotl-kview))
	(kview:create (buffer-name))) ;; sets buffer-local `kotl-kview'
    ;; If buffer has not yet been formatted for editing, format it.
    (let (version)
      ;; Koutline file that has been loaded but not yet formatted for editing.
      (if (setq version (kfile:is-p))
          ;; Koutline file that has been loaded and formatted for editing.
	  (if (kview:is-p kotl-kview)
	      ;; The buffer might have been widened for inspection, so narrow to cells
	      ;; only.
	      (kfile:narrow-to-kcells)
	    (kfile:read
	     (current-buffer)
	     (and (hypb:buffer-file-name) (file-exists-p (hypb:buffer-file-name)))
	     version)
	    (kvspec:activate))
	;; New koutline buffer or a foreign text buffer that must be converted to
	;; koutline format.
	(kfile:create (current-buffer))
	(kvspec:activate)))
    ;; We have been converting a buffer from a foreign format to a koutline.
    ;; Now that it is converted, ensure that `kotl-previous-mode' is set to
    ;; koutline.
    (with-suppressed-warnings ((free-vars kotl-previous-mode))
      (setq kotl-previous-mode 'kotl-mode))
    (run-mode-hooks 'kotl-mode-hook)
    (unless (string-prefix-p hyrolo-display-buffer (buffer-name))
      (add-hook 'change-major-mode-hook #'kotl-mode:show-all nil t))))