Function: hbmap:dir-operate

hbmap:dir-operate is a byte-compiled function defined in hbmap.el.

Signature

(hbmap:dir-operate PRED DIR-NAME FORM &optional NO-SAVE)

Documentation

If PRED called on DIR-NAME is non-nil, evaluate FORM.

Return t if PRED evaluation is successful and nil when not, except when hbmap is not readable or writable, in which case return a symbol indicating the error. Optional NO-SAVE disables saving of the map after operation.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hbmap.el
;;; ************************************************************************
;;; Private functions
;;; ************************************************************************

(defun hbmap:dir-operate (pred dir-name form &optional no-save)
  "If PRED called on DIR-NAME is non-nil, evaluate FORM.
Return t if PRED evaluation is successful and nil when not, except when
hbmap is not readable or writable, in which case return a symbol indicating
the error.  Optional NO-SAVE disables saving of the map after operation."
  (save-excursion
    (let ((buf (unless (and (file-exists-p hbmap:dir-filename)
			    (not (file-readable-p hbmap:dir-filename)))
		 (find-file-noselect hbmap:dir-filename))))
      (if buf
	  (progn (set-buffer buf)
		 (when (funcall pred dir-name)
		   (setq buffer-read-only nil)
		   (eval form)
		   (cond (no-save
			  t)
			 ((file-writable-p (hypb:buffer-file-name))
			  (save-buffer)
			  t)
			 (t 'hbmap-not-writable))))
	'hbmap-not-readable))))