Function: hyrolo-sort

hyrolo-sort is an autoloaded, interactive and byte-compiled function defined in hyrolo.el.

Signature

(hyrolo-sort &optional HYROLO-FILE)

Documentation

Sort up to 14 levels of entries in HYROLO-FILE (default is personal hyrolo).

Assume entries are delimited by one or more * characters. Return list of number of groupings at each entry level.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hyrolo.el
;;;###autoload
(defun hyrolo-sort (&optional hyrolo-file)
  "Sort up to 14 levels of entries in HYROLO-FILE (default is personal hyrolo).
Assume entries are delimited by one or more `*' characters.
Return list of number of groupings at each entry level."
  (interactive
   (list (let ((default "")
	       (file))
	   (setq file
		 (completing-read
		  (format "Sort rolo file (default %s): "
			  (file-name-nondirectory
			   (setq default
				 (if (and (hypb:buffer-file-name)
					  (memq
					   t (mapcar
					      (lambda (file)
						(equal (hypb:buffer-file-name)
						       (expand-file-name file)))
					      (hyrolo-get-file-list))))
				     (hypb:buffer-file-name)
				   (car (hyrolo-get-file-list))))))
		  (mapcar #'list (hyrolo-get-file-list))))
	   (if (string-empty-p file) default file))))
  (when (or (not hyrolo-file) (equal hyrolo-file ""))
    (setq hyrolo-file (car (hyrolo-get-file-list))))
  (unless (and (stringp hyrolo-file) (file-readable-p hyrolo-file))
    (error "(hyrolo-sort): Invalid or unreadable file: %s" hyrolo-file))
  (let ((level-regexp (regexp-quote "**************"))
	(buf-existed-flag (get-file-buffer hyrolo-file))
	(entries-per-level-list)
	(n))
    (with-current-buffer (hyrolo-find-file-noselect hyrolo-file)
      (while (not (string-empty-p level-regexp))
	(setq n (hyrolo-sort-level level-regexp))
	(when (or (/= n 0) entries-per-level-list)
	  (setq entries-per-level-list (cons (list (/ (length level-regexp) 2) n)
					     entries-per-level-list)))
	;; Subtract 2 here because there are two chars per star when
	;; regexp-quoted: \\*
	(setq level-regexp (substring level-regexp 0 (- (length level-regexp) 2))))
      (goto-char (point-min))
      (unless buf-existed-flag
	(hyrolo-kill-buffer (current-buffer)))
      entries-per-level-list)))