Function: org-export--dispatch-action

org-export--dispatch-action is a byte-compiled function defined in ox.el.gz.

Signature

(org-export--dispatch-action PROMPT ALLOWED-KEYS ENTRIES OPTIONS FIRST-KEY EXPERTP)

Documentation

Read a character from command input and act accordingly.

PROMPT is the displayed prompt, as a string. ALLOWED-KEYS is a list of characters available at a given step in the process. ENTRIES is a list of menu entries. OPTIONS, FIRST-KEY and EXPERTP are the same as defined in org-export--dispatch-ui, which see.

Toggle export options when required. Otherwise, return value is a list with action as CAR and a list of interactive export options as CDR.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
(defun org-export--dispatch-action
    (prompt allowed-keys entries options first-key expertp)
  "Read a character from command input and act accordingly.

PROMPT is the displayed prompt, as a string.  ALLOWED-KEYS is
a list of characters available at a given step in the process.
ENTRIES is a list of menu entries.  OPTIONS, FIRST-KEY and
EXPERTP are the same as defined in `org-export--dispatch-ui',
which see.

Toggle export options when required.  Otherwise, return value is
a list with action as CAR and a list of interactive export
options as CDR."
  (let (key)
    ;; Scrolling: when in non-expert mode, act on motion keys (C-n,
    ;; C-p, SPC, DEL).
    (while (and (setq key (read-char-exclusive prompt))
		(not expertp)
		;; FIXME: Don't use C-v (22) here, as it is used as a
		;; modifier key in the export dispatch.
		(memq key '(14 16 ?\s ?\d 134217846)))
      (org-scroll key t))
    (cond
     ;; Ignore undefined associations.
     ((not (memq key allowed-keys))
      (ding)
      (unless expertp (message "Invalid key") (sit-for 1))
      (org-export--dispatch-ui options first-key expertp))
     ;; q key at first level aborts export.  At second level, cancel
     ;; first key instead.
     ((eq key ?q) (if (not first-key) (user-error "Export aborted")
		    (org-export--dispatch-ui options nil expertp)))
     ;; Help key: Switch back to standard interface if expert UI was
     ;; active.
     ((eq key ??) (org-export--dispatch-ui options first-key nil))
     ;; Send request for template insertion along with export scope.
     ((eq key ?#) (cons 'template (memq 'subtree options)))
     ;; Switch to asynchronous export stack.
     ((eq key ?&) '(stack))
     ;; Toggle options: C-b (2) C-v (22) C-s (19) C-f (6) C-a (1).
     ((memq key '(2 22 19 6 1))
      (org-export--dispatch-ui
       (let ((option (cl-case key (2 'body) (22 'visible) (19 'subtree)
			      (6 'force) (1 'async))))
	 (if (memq option options) (remq option options)
	   (cons option options)))
       first-key expertp))
     ;; Action selected: Send key and options back to
     ;; `org-export-dispatch'.
     ((or first-key (functionp (nth 2 (assq key entries))))
      (cons (cond
	     ((not first-key) (nth 2 (assq key entries)))
	     ;; Publishing actions are hard-coded.  Send a special
	     ;; signal to `org-export-dispatch'.
	     ((eq first-key ?P)
	      (cl-case key
		(?f 'publish-current-file)
		(?p 'publish-current-project)
		(?x 'publish-choose-project)
		(?a 'publish-all)))
	     ;; Return first action associated to FIRST-KEY + KEY
	     ;; path. Indeed, derived backends can share the same
	     ;; FIRST-KEY.
	     (t (catch 'found
		  (dolist (entry (member (assq first-key entries) entries))
		    (let ((match (assq key (nth 2 entry))))
		      (when match (throw 'found (nth 2 match))))))))
	    options))
     ;; Otherwise, enter sub-menu.
     (t (org-export--dispatch-ui options key expertp)))))