Function: hypb:display-file-with-logo

hypb:display-file-with-logo is an autoloaded and byte-compiled function defined in hypb.el.

Signature

(hypb:display-file-with-logo FILE)

Documentation

Display a text FILE in view mode with the Hyperbole banner prepended.

If FILE is not an absolute path, expand it relative to hyperb:dir.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hypb.el
;;;###autoload
(defun hypb:display-file-with-logo (file)
  "Display a text FILE in view mode with the Hyperbole banner prepended.
If FILE is not an absolute path, expand it relative to `hyperb:dir'."
  (unless (stringp file)
    (error "(hypb:display-file-with-logo): 'file' must be a string, not '%s'" file))
  (unless (file-name-absolute-p file)
    (setq file (expand-file-name file hyperb:dir)))
  (let ((existing-buf (when (stringp file) (get-file-buffer file)))
	(hsys-org-enable-smart-keys hsys-org-enable-smart-keys))

    ;; Ensure Smart Keys do not defer to Org mode when running tests noninteractively
    (when noninteractive
      (setq hsys-org-enable-smart-keys t))

    (when (and existing-buf noninteractive)
      ;; Likely are running tests when running non-interactively, so
      ;; kill existing buffer, so each test run starts from scratch
      ;; and is consistent.  Trigger an error if buffer has been
      ;; modified.
      (when (buffer-modified-p existing-buf)
	(error "(hypb:display-file-with-logo): Attempt to kill modified buffer: %s" existing-buf))
      (when (kill-buffer existing-buf)
	(setq existing-buf nil)))

    ;; A stub for the `id-browse-file' function is defined in
    ;; "hversion.el" when not running in InfoDock.
    (if (eq (symbol-function #'id-browse-file) #'view-file)
	(find-file file)
      ;; Running under InfoDock
      (id-browse-file file))

    (unless existing-buf
      (let ((buffer-read-only))
	(hypb:insert-hyperbole-banner))
      (goto-char (point-min))
      (set-window-start (selected-window) 1)
      (set-buffer-modified-p nil)
      (org-mode)
      (setq-local org-cycle-global-at-bob t)
      (view-mode)
      ;; Ensure no initial folding of the buffer, possibly from a hook
      (with-suppressed-warnings ((obsolete org-show-all))
        (if (fboundp 'org-fold-show-all)
	    (org-fold-show-all)
	  (org-show-all)))
      ;; On some versions of Emacs like Emacs28, need a slight delay
      ;; for file loading before searches will work properly.
      ;; Otherwise, "test/demo-tests.el" may fail.
      (sit-for 0.10))))