Variable: gptel--header-line-info

gptel--header-line-info is a variable defined in gptel.el.

Value

Large value
(:eval
 (let*
     ((model (gptel--model-name gptel-model))
      (system
       (propertize
	(buttonize
	 (format "[Prompt: %s]"
		 (or
		  (car-safe
		   (rassoc gptel-system-prompt gptel-directives))
		  (gptel--describe-directive gptel-system-prompt 15)))
	 (lambda (&rest _) (gptel-system-prompt)))
	'mouse-face 'highlight 'help-echo "System message for session"))
      (context
       (and gptel-context
	    (cl-loop for entry in gptel-context if
		     (bufferp (or (car-safe entry) entry)) count it
		     into bufs else count
		     (stringp (or (car-safe entry) entry)) into files
		     finally return
		     (propertize
		      (buttonize
		       (concat "["
			       (and (> bufs 0) (format "%d buf" bufs))
			       (and (> bufs 1) "s")
			       (and (> bufs 0) (> files 0) ", ")
			       (and (> files 0)
				    (format "%d file" files))
			       (and (> files 1) "s") "]")
		       (lambda (&rest _) (require 'gptel-context)
			 (gptel-context--buffer-setup)))
		      'mouse-face 'highlight 'help-echo
		      "Active gptel context"))))
      (toggle-track-media
       (lambda (&rest _)
	 (setq-local gptel-track-media (not gptel-track-media))
	 (if gptel-track-media
	     (progn
	       (run-hooks 'gptel-refresh-buffer-hook)
	       (message "Sending media from included links."))
	   (without-restriction (gptel--annotate-link-clear))
	   (message "Ignoring links.  Only link text will be sent."))
	 (run-at-time 0 nil #'force-mode-line-update)))
      (track-media
       (and (gptel--model-capable-p 'media)
	    (if gptel-track-media
		(propertize
		 (buttonize "[Media: Send]" toggle-track-media)
		 'mouse-face 'highlight 'help-echo
		 "Sending media from links/urls when supported.\nClick to toggle")
	      (propertize (buttonize "[Media: No]" toggle-track-media)
			  'mouse-face 'highlight 'help-echo
			  "Ignoring media from links/urls.\nClick to toggle"))))
      (toggle-tools
       (lambda (&rest _) (interactive)
	 (run-at-time 0 nil
		      (lambda nil (call-interactively #'gptel-tools)))))
      (tools
       (when (and gptel-use-tools gptel-tools)
	 (propertize
	  (buttonize
	   (pcase (length gptel-tools)
	     (0 "[No tools]") (1 "[1 tool]")
	     (len (format "[%d tools]" len)))
	   toggle-tools)
	  'mouse-face 'highlight 'help-echo "Select tools")))
      (usage
       (and-let*
	   ((idx (car-safe gptel--token-usage-strings))
	    (entry
	     (or (nth (1+ idx) gptel--token-usage-strings)
		 "[usage...]"))
	    (noinfo "[No info]")
	    (toggle-usage
	     (lambda (strings) (interactive)
	       (and (car-safe strings)
		    (cl-callf (lambda (pos) (% (1+ pos) 2))
			(car strings))))))
	 (buttonize entry toggle-usage gptel--token-usage-strings
		    (concat
		     "Token usage (C = cached tokens)\nLast request: "
		     (or (cadr gptel--token-usage-strings) noinfo)
		     "\nThis buffer:  "
		     (or (caddr gptel--token-usage-strings) noinfo))))))
   (let
       ((rhs
	 (concat usage (and usage " ") tools (and tools " ")
		 track-media (and track-media " ") context
		 (and context " ") system " "
		 (propertize
		  (buttonize (concat "[" model "]")
			     (lambda (&rest _) (gptel-menu)))
		  'mouse-face 'highlight 'help-echo "Model in use"))))
     (concat
      (propertize " " 'display
		  (if
		      (and (fboundp 'string-pixel-width)
			   (display-graphic-p))
		      `(space :align-to
			      (- right (,(string-pixel-width rhs))))
		    `(space :align-to
			    (- right ,(+ 5 (string-width rhs))))))
      rhs))))

Documentation

Information segment for the header-line in gptel-mode(var)/gptel-mode(fun).

Source Code

;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel.el
;;;; Header line formatting
(defvar gptel--header-line-info
  '(:eval
    (let* ((model (gptel--model-name gptel-model))
           (system
            (propertize
             (buttonize
              (format "[Prompt: %s]"
                      (or (car-safe (rassoc gptel-system-prompt gptel-directives))
                          (gptel--describe-directive gptel-system-prompt 15)))
              (lambda (&rest _) (gptel-system-prompt)))
             'mouse-face 'highlight
             'help-echo "System message for session"))
           (context
            (and gptel-context
                 (cl-loop
                  for entry in gptel-context
                  if (bufferp (or (car-safe entry) entry)) count it into bufs
                  else count (stringp (or (car-safe entry) entry)) into files
                  finally return
                  (propertize
                   (buttonize
                    (concat "[" (and (> bufs 0) (format "%d buf" bufs))
                            (and (> bufs 1) "s")
                            (and (> bufs 0) (> files 0) ", ")
                            (and (> files 0) (format "%d file" files))
                            (and (> files 1) "s") "]")
                    (lambda (&rest _)
                      (require 'gptel-context)
                      (gptel-context--buffer-setup)))
                   'mouse-face 'highlight
                   'help-echo "Active gptel context"))))
           (toggle-track-media
            (lambda (&rest _)
              (setq-local gptel-track-media (not gptel-track-media))
              (if gptel-track-media
                  (progn
                    (run-hooks 'gptel-refresh-buffer-hook)
                    (message "Sending media from included links."))
                (without-restriction (gptel--annotate-link-clear))
                (message "Ignoring links.  Only link text will be sent."))
              (run-at-time 0 nil #'force-mode-line-update)))
           (track-media
            (and (gptel--model-capable-p 'media)
                 (if gptel-track-media
                     (propertize
                      (buttonize "[Media: Send]" toggle-track-media)
                      'mouse-face 'highlight
                      'help-echo
                      "Sending media from links/urls when supported.\nClick to toggle")
                   (propertize
                    (buttonize "[Media: No]" toggle-track-media)
                    'mouse-face 'highlight
                    'help-echo
                    "Ignoring media from links/urls.\nClick to toggle"))))
           (toggle-tools (lambda (&rest _) (interactive)
                           (run-at-time 0 nil
                                        (lambda () (call-interactively #'gptel-tools)))))
           (tools (when (and gptel-use-tools gptel-tools)
                    (propertize
                     (buttonize (pcase (length gptel-tools)
                                  (0 "[No tools]") (1 "[1 tool]")
                                  (len (format "[%d tools]" len)))
                                toggle-tools)
                     'mouse-face 'highlight
                     'help-echo "Select tools")))
           (usage
            (and-let* ((idx (car-safe gptel--token-usage-strings))
                       (entry (or (nth (1+ idx) gptel--token-usage-strings)
                                  "[usage...]"))
                       (noinfo "[No info]")
                       (toggle-usage
                        (lambda (strings) (interactive)
                          (and (car-safe strings)
                               (cl-callf (lambda (pos) (% (1+ pos) 2)) (car strings))))))
              (buttonize entry toggle-usage gptel--token-usage-strings
                         (concat "Token usage (C = cached tokens)\nLast request: "
                                 (or (cadr gptel--token-usage-strings) noinfo)
                                 "\nThis buffer:  "
                                 (or (caddr gptel--token-usage-strings) noinfo))))))
      (let ((rhs (concat
                  usage (and usage " ") tools (and tools " ")
                  track-media (and track-media " ")
                  context (and context " ") system " "
                  (propertize
                   (buttonize (concat "[" model "]")
                              (lambda (&rest _) (gptel-menu)))
                   'mouse-face 'highlight
                   'help-echo "Model in use"))))
        (concat
         (propertize
          " " 'display
          (if (and (fboundp 'string-pixel-width)
                   (display-graphic-p))
              `(space :align-to (- right (,(string-pixel-width rhs))))
            `(space :align-to (- right ,(+ 5 (string-width rhs))))))
         rhs))))
  "Information segment for the header-line in `gptel-mode'.")