Function: org-columns-next-allowed-value
org-columns-next-allowed-value is an interactive and byte-compiled
function defined in org-colview.el.gz.
Signature
(org-columns-next-allowed-value &optional PREVIOUS NTH)
Documentation
Switch to the next allowed value for this column.
When PREVIOUS is set, go to the previous value. When NTH is an integer, select that value.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-colview.el.gz
(defun org-columns-next-allowed-value (&optional previous nth)
"Switch to the next allowed value for this column.
When PREVIOUS is set, go to the previous value. When NTH is
an integer, select that value."
(interactive)
(org-columns-check-computed)
(let* ((column (org-current-text-column))
(visible-column (current-column))
(key (get-char-property (point) 'org-columns-key))
(value (get-char-property (point) 'org-columns-value))
(pom (or (get-text-property (line-beginning-position) 'org-hd-marker)
(point)))
(allowed
(let ((all
(or (org-property-get-allowed-values pom key)
(pcase (nth column org-columns-current-fmt-compiled)
(`(,_ ,_ ,_ ,(or "X" "X/" "X%") ,_) '("[ ]" "[X]")))
(org-colview-construct-allowed-dates value))))
(if previous (reverse all) all))))
(when (equal key "ITEM") (error "Cannot edit item headline from here"))
(unless (or allowed (member key '("SCHEDULED" "DEADLINE" "CLOCKSUM")))
(error "Allowed values for this property have not been defined"))
(let* ((l (length allowed))
(new
(cond
((member key '("SCHEDULED" "DEADLINE" "CLOCKSUM"))
(if previous 'earlier 'later))
((integerp nth)
(when (> (abs nth) l)
(user-error "Only %d allowed values for property `%s'" l key))
(nth (mod (1- nth) l) allowed))
((member value allowed)
(when (= l 1) (error "Only one allowed value for this property"))
(or (nth 1 (member value allowed)) (car allowed)))
(t (car allowed))))
(action (lambda () (org-entry-put pom key new))))
(cond
((eq major-mode 'org-agenda-mode)
(org-columns--call action)
;; The following let preserves the current format, and makes
;; sure that in only a single file things need to be updated.
(let* ((org-overriding-columns-format org-columns-current-fmt)
(buffer (marker-buffer pom))
(org-agenda-contributing-files
(list (with-current-buffer buffer
(buffer-file-name (buffer-base-buffer))))))
(org-agenda-columns)))
(t
(let ((inhibit-read-only t))
(remove-text-properties (line-end-position 0) (line-end-position)
'(read-only t))
(org-columns--call action))
;; Some properties can modify headline (e.g., "TODO"), and
;; possible shuffle overlays. Make sure they are still all at
;; the right place on the current line.
(let ((org-columns-inhibit-recalculation)) (org-columns-redo))
(org-columns-update key)
(org-move-to-column visible-column))))))