Function: hargs:at-p
hargs:at-p is a byte-compiled function defined in hargs.el.
Signature
(hargs:at-p &optional NO-DEFAULT)
Documentation
Return thing at point, if of hargs:reading-type type, or default.
If optional argument NO-DEFAULT is non-nil, nil is returned instead of any default values.
Caller should have checked whether an argument is presently being read and has set hargs:reading-type to an appropriate argument type. Handles all of the interactive argument types that hargs:iform-read does.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hargs.el
(defun hargs:at-p (&optional no-default)
"Return thing at point, if of hargs:reading-type type, or default.
If optional argument NO-DEFAULT is non-nil, nil is returned instead of any
default values.
Caller should have checked whether an argument is presently being read
and has set `hargs:reading-type' to an appropriate argument type.
Handles all of the interactive argument types that `hargs:iform-read' does."
(cond ;; vertico-mode
((and (null hargs:reading-type)
(bound-and-true-p vertico-mode)
;; Ensure vertico is prompting for an argument
(vertico--command-p nil (current-buffer))
(active-minibuffer-window))
(cond
((or
;; Action Key press
(and action-key-depressed-flag
(eq (selected-window) (active-minibuffer-window)))
;; Action Mouse Key press
(and action-key-release-args
(fboundp #'vertico-mouse--index)
(eq (posn-window (event-end action-key-release-args))
(active-minibuffer-window))))
(with-selected-window (active-minibuffer-window)
(let ((index (when (and action-key-release-args
(fboundp #'vertico-mouse--index))
(vertico-mouse--index action-key-release-args)))
mini
mini-to-point)
(if index
(save-excursion
(vertico--goto index)
(vertico--update t)
(vertico--candidate))
;; Assume event occurred within the minibufer-contents
;; and return just the contents before point so
;; that those after are deleted and more
;; completions are shown.
(setq mini (minibuffer-contents-no-properties))
;; The minibuffer may have some read-only contents
;; at the beginning, e.g. M-x, not included in the 'mini'
;; string, so we have to offset the max index into
;; the string in such cases and protect against
;; when point is set into this read-only area with
;; the 'max' call below.
(setq mini-to-point (substring mini 0 (max (- (point) (point-max)) (- (length mini)))))
(list (if (and (= (point) (point-max)) (string-empty-p mini-to-point))
mini
mini-to-point)
nil)))))
(t (list (vertico--candidate) t))))
((and (null hargs:reading-type)
(or
;; Action Key press
(and action-key-depressed-flag
(eq (selected-window) (active-minibuffer-window)))
;; Action Mouse Key press
(and action-key-release-args
(eq (posn-window (event-end action-key-release-args))
(active-minibuffer-window)))))
;; Event occurred within the minibufer-contents. Return
;; just the contents before point so that those after are
;; deleted and more completions are shown.
(let* ((mini (minibuffer-contents-no-properties))
(mini-to-point (substring mini 0 (max (- (point) (point-max)) (- (length mini))))))
(list (if (and (= (point) (point-max)) (string-empty-p mini-to-point))
mini
mini-to-point)
nil)))
((and (eq hargs:reading-type 'kcell)
(derived-mode-p 'kotl-mode)
(not (looking-at "^$")))
(kcell-view:label))
((and (eq hargs:reading-type 'klink)
(not (looking-at "^$")))
(if (derived-mode-p 'kotl-mode)
;; Here we get the button src default-directory, not the
;; default-directory of the linked to kcell.
(list (kcell-view:reference nil (hattr:get 'hbut:current 'dir)))
(let ((hargs:reading-type 'file))
(list (hargs:at-p)))))
((eq hargs:reading-type 'kvspec)
(read-string "Koutline view spec: "
(when (boundp 'kvspec:current) kvspec:current)))
((eolp) nil)
((and (eq hargs:reading-type 'hmenu)
(eq (selected-window) (minibuffer-window)))
(char-to-string
(save-excursion
(cond ((save-excursion (search-forward ">" nil t))
;; In menu prefix
1)
((search-backward " " nil t)
;; On a menu item, return the first capitalized
;; char or if none, the first character
(skip-chars-forward " ")
(let (case-fold-search)
(if (looking-at "[^ \t\nA-Z]*[A-Z]")
(char-before (match-end 0))
(following-char))))
;; At the end of the menu
(t 0)))))
((let ((completion (hargs:completion t)))
(when completion
(list completion t))))
((eq hargs:reading-type 'ebut) (ebut:label-p 'as-label))
((eq hargs:reading-type 'ibut) (ibut:label-p 'as-label))
((eq hargs:reading-type 'gbut)
(when (eq (current-buffer) (get-file-buffer (gbut:file)))
(hbut:label-p 'as-label)))
((eq hargs:reading-type 'hbut) (hbut:label-p 'as-label))
((hbut:label-p) nil)
((eq hargs:reading-type 'file)
(cond ((derived-mode-p 'dired-mode)
(let ((file (dired-get-filename nil t)))
(and file (hpath:absolute-to file))))
;; Delimited file name.
((hpath:at-p 'file))
;; Unquoted remote file name.
((hpath:is-p (hpath:remote-at-p) 'file))
(no-default nil)
;; Possibly non-existent file name
((hpath:at-p 'file 'non-exist))
((hypb:buffer-file-name))))
((eq hargs:reading-type 'directory)
(cond ((derived-mode-p 'dired-mode)
(let ((dir (or (smart-dired-pathname-up-to-point t)
(dired-get-filename nil t))))
(and dir (setq dir (hpath:absolute-to dir))
(file-directory-p dir) dir)))
;; Delimited directory name.
((hpath:at-p 'directory))
;; Unquoted remote directory name.
((hpath:is-p (hpath:remote-at-p) 'directory))
(no-default nil)
;; Possibly non-existent directory name
((hpath:at-p 'directory 'non-exist))
(default-directory)))
((eq hargs:reading-type 'string)
(or (hargs:delimited "\"" "\"") (hargs:delimited "'" "'")
(hargs:delimited "`" "'")))
((memq hargs:reading-type '(actype actypes))
(let ((name (hargs:find-tag-default)))
(car (set:member name (htype:names 'actypes)))))
((memq hargs:reading-type '(ibtype ibtypes))
(let ((name (hargs:find-tag-default)))
(car (set:member name (htype:names 'ibtypes)))))
((eq hargs:reading-type 'sexpression) (hargs:sexpression-p))
((memq hargs:reading-type '(Info-index-item Info-node))
(when (eq major-mode 'Info-mode)
(let ((file (Info-current-filename-sans-extension))
(node (cond ((Info-note-at-p))
((Info-menu-item-at-p))
(t Info-current-node))))
(cond ((and (stringp node) (string-match "\\`\(" node))
node)
(file
(concat "(" file ")" node))
(t node)))))
((eq hargs:reading-type 'mail)
(and (hmail:reader-p) (hypb:buffer-file-name)
(prin1-to-string (list (rmail:msg-id-get) (hypb:buffer-file-name)))))
((eq hargs:reading-type 'symbol)
(let ((sym (hargs:find-tag-default)))
(when (or (fboundp sym) (boundp sym)) sym)))
((eq hargs:reading-type 'buffer)
(let ((tag (hargs:find-tag-default)))
(if (member tag (mapcar #'buffer-name (buffer-list)))
tag
(buffer-name))))
((eq hargs:reading-type 'character)
(following-char))
((eq hargs:reading-type 'key)
(require 'hib-kbd)
(let ((key-seq (hbut:label-p 'as-label "{" "}")))
(when key-seq (kbd-key:normalize key-seq))))
((eq hargs:reading-type 'integer)
(save-excursion (skip-chars-backward "-0-9")
(when (looking-at "-?[0-9]+")
(read (current-buffer)))))))