Function: logview--find-view

logview--find-view is a natively compiled function defined in logview.el.

Signature

(logview--find-view VIEW &optional INTERNAL)

Source Code

;; Defined in /nix/store/3zkn9hgpv447zb8nrg55d9x2ynmmrk40-emacs-packages-deps/share/emacs/site-lisp/elpa/logview-20260218.2013/logview.el
(defun logview--find-view (view &optional internal)
  (if (or (stringp view) (integerp view))
      (let ((all-views (logview--views))
            matches)
        (while all-views
          (let ((candidate (pop all-views)))
            (when (and (if (stringp view)
                           (string= (plist-get candidate :name) view)
                         (equal (plist-get candidate :index) view))
                       (or (null (plist-get candidate :submode)) (string= (plist-get candidate :submode) logview--submode-name)))
              (push candidate matches))))
        (cond ((null matches)
               (funcall (if internal #'error #'user-error)
                        (if (stringp view) "Unknown view `%s'" "There is no view with quick access index %d") view))
              ((cdr matches)
               (apply (if internal #'error #'user-error)
                      (if (stringp view)
                          `("There are at least two views named `%s'" ,view)
                        `("There are at least two views with quick access index %d (`%s' and `%s')"
                          ,view ,(plist-get (car matches) :name) ,(plist-get (cadr matches) :name)))))
              (t
               (car matches))))
    (if (and (listp view) (stringp (plist-get view :name)))
        view
      (unless internal
        (error "Invalid view object `%S'" view)))))