Function: hyrolo-kill

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

Signature

(hyrolo-kill NAME &optional FILE)

Documentation

Kill a rolo entry given by NAME within hyrolo-file-list.

With prefix argument, prompts for optional FILE to locate entry within. NAME may be of the form: parent/child to kill child below a parent entry which begins with the parent string. Return t if entry is killed, nil otherwise.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hyrolo.el
;;;###autoload
(defun hyrolo-kill (name &optional file)
  "Kill a rolo entry given by NAME within `hyrolo-file-list'.
With prefix argument, prompts for optional FILE to locate entry within.
NAME may be of the form: parent/child to kill child below a parent entry
which begins with the parent string.
Return t if entry is killed, nil otherwise."
  (interactive (list
		(hsys-consult-grep-headlines-read-regexp
		 #'hyrolo-consult-grep "Kill rolo entry named")
		current-prefix-arg))
  (if (or (not (stringp name)) (string-empty-p name))
      (error "(hyrolo-kill): Invalid name: `%s'" name))
  (if (and (called-interactively-p 'interactive) current-prefix-arg)
      (setq file (completing-read "Entry's File: "
				  (mapcar #'list (hyrolo-get-file-list)))))
  (let ((file-list (if file (list file) (hyrolo-get-file-list)))
	(killed))
    (unless file
      (setq file (car file-list)))
    (save-excursion
      (if (if (and (hsys-consult-active-p)
		   (string-match "\\([^ \t\n\r\"'`]*[^ \t\n\r:\"'`0-9]\\): ?\\([1-9][0-9]*\\)[ :]"
				 name))
	      (hyrolo-to (substring name (match-end 0))
			 (list (setq file (match-string-no-properties 1 name))))
	    (hyrolo-to name file-list))
	  (progn
	    (setq file (hypb:buffer-file-name))
	    (if (file-writable-p file)
		(let ((kill-op
		       (lambda (start _level-len)
			 (kill-region
			  start (hyrolo-to-entry-end t))
			 (setq killed t)
			 (hyrolo-save-buffer)
			 (hyrolo-kill-buffer)))
		      (case-fold-search)
		      start end level-len)
		  (setq buffer-read-only nil)
		  (re-search-backward hyrolo-hdr-and-entry-regexp nil t)
		  (setq end (match-end 0))
		  (setq start (line-beginning-position)
			level-len (length (buffer-substring-no-properties start end)))
		  (goto-char end)
		  (skip-chars-forward " \t")
		  (if (called-interactively-p 'interactive)
		      (let ((entry-line (buffer-substring-no-properties
					 (point)
					 (min (+ (point) 60)
					      (progn (end-of-line) (point))))))
			(if (y-or-n-p (format "Kill `%s...'? " entry-line))
			    (progn
			      (funcall kill-op start level-len)
			      (message "Killed"))
			  (message "Aborted")))
		    (funcall kill-op start level-len)))
	      (message
	       "(hyrolo-kill): Entry found but file not writable: `%s'" file)
	      (beep)))
	(message "(hyrolo-kill): `%s' not found." name)
	(beep)))
    killed))