Closed stardiviner closed 1 year ago
ps. Use (setq chatgpt-shell-logging t)
and look out for *chatgpt-log*
buffer.
@xenodium Thanks for support. I tested the latest code, it only logged the request. No response message logged. Hope it can be added like my PR.
Seems like the PR outputs the response when it's empty, thus no output?
Or is this more about explicitly recording there was no response in the logs?
Originally because ob-chatgpt-shell return nothing, so I consider to add log messages. Logging the process respond will contains the data or error message. So I want to log the respond too.
Now I think don't need to add if condition to check whether response is empty.
Logging the process respond will contains the data or error message.
Logging status, data, and response as of ff4ae00e20c822f37bbd6fd03e260a5e021cdaf2
Thanks for quick update.
I got error:
Seems shell-maker--write-output-to-log-buffer
passed nil
string to replace-regexp-in-string
. Maybe need to filter out this case?
Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
replace-regexp-in-string("sk-,,,,,,,,,,,,,,,,,,,,," "SK-REDACTED-OPENAI-KEY" nil)
(if (chatgpt-shell-openai-key) (replace-regexp-in-string (regexp-quote (chatgpt-shell-openai-key)) "SK-REDACTED-OPENAI-KEY" output) output)
(closure (t) (output) (if (chatgpt-shell-openai-key) (replace-regexp-in-string (regexp-quote (chatgpt-shell-openai-key)) "SK-REDACTED-OPENAI-KEY" output) output))(nil)
funcall((closure (t) (output) (if (chatgpt-shell-openai-key) (replace-regexp-in-string (regexp-quote (chatgpt-shell-openai-key)) "SK-REDACTED-OPENAI-KEY" output) output)) nil)
(setq output (funcall (let ((cl-x config)) (progn (or (let ((cl-x cl-x)) (progn (and ... t))) (signal 'wrong-type-argument (list 'shell-maker-config cl-x))) (aref cl-x 7))) output))
(progn (setq output (funcall (let ((cl-x config)) (progn (or (let (...) (progn ...)) (signal 'wrong-type-argument (list ... cl-x))) (aref cl-x 7))) output)))
(if (let ((cl-x config)) (progn (or (let ((cl-x cl-x)) (progn (and (memq ... cl-struct-shell-maker-config-tags) t))) (signal 'wrong-type-argument (list 'shell-maker-config cl-x))) (aref cl-x 7))) (progn (setq output (funcall (let ((cl-x config)) (progn (or (let ... ...) (signal ... ...)) (aref cl-x 7))) output))))
(progn (if (let ((cl-x config)) (progn (or (let ((cl-x cl-x)) (progn (and ... t))) (signal 'wrong-type-argument (list 'shell-maker-config cl-x))) (aref cl-x 7))) (progn (setq output (funcall (let ((cl-x config)) (progn (or ... ...) (aref cl-x 7))) output)))) (save-current-buffer (set-buffer (get-buffer-create (format "*%s-log*" (shell-maker-process-name config)))) (let ((beginning-of-input (goto-char (point-max)))) (insert output) (if (and (require 'json nil t) (condition-case nil (progn (shell-maker--json-parse-string output)) (error nil))) (progn (json-pretty-print beginning-of-input (point)))))))
(if (and shell-maker-logging config) (progn (if (let ((cl-x config)) (progn (or (let (...) (progn ...)) (signal 'wrong-type-argument (list ... cl-x))) (aref cl-x 7))) (progn (setq output (funcall (let (...) (progn ... ...)) output)))) (save-current-buffer (set-buffer (get-buffer-create (format "*%s-log*" (shell-maker-process-name config)))) (let ((beginning-of-input (goto-char (point-max)))) (insert output) (if (and (require 'json nil t) (condition-case nil (progn ...) (error nil))) (progn (json-pretty-print beginning-of-input (point))))))))
shell-maker--write-output-to-log-buffer(nil #s(shell-maker-config :name "ChatGPT" :prompt nil :prompt-regexp nil :validate-command (closure (t) (_command) (if chatgpt-shell-openai-key nil "Variable `chatgpt-shell-openai-key' needs to be se...")) :execute-command (closure (t) (_command history callback error-callback) (shell-maker-async-shell-command (chatgpt-shell--make-curl-request-command-list (chatgpt-shell--make-payload history)) chatgpt-shell-streaming #'chatgpt-shell--extract-chatgpt-response callback error-callback)) :on-command-finished (closure (t) (command output) (chatgpt-shell--put-source-block-overlays) (run-hook-with-args 'chatgpt-shell-after-command-functions command output)) :redact-log-output (closure (t) (output) (if (chatgpt-shell-openai-key) (replace-regexp-in-string (regexp-quote (chatgpt-shell-openai-key)) "SK-REDACTED-OPENAI-KEY" output) output))))
(let* ((buffer (current-buffer)) (command (chatgpt-shell--make-curl-request-command-list (let ((request-data (list ... ...))) (if (or temperature chatgpt-shell-model-temperature) (progn (setq request-data ...))) request-data))) (config chatgpt-shell--config) (status (progn (shell-maker--write-output-to-log-buffer "// Request\n\n" config) (shell-maker--write-output-to-log-buffer (string-join command " ") config) (shell-maker--write-output-to-log-buffer "\n\n" config) (apply #'call-process (seq-first command) nil buffer nil (cdr command)))) (data (buffer-substring-no-properties (point-min) (point-max))) (response (chatgpt-shell--extract-chatgpt-response data))) (shell-maker--write-output-to-log-buffer (format "// Data (status: %d)\n\n" status) config) (shell-maker--write-output-to-log-buffer data config) (shell-maker--write-output-to-log-buffer "\n\n" config) (shell-maker--write-output-to-log-buffer "// Response\n\n" config) (shell-maker--write-output-to-log-buffer response config) (shell-maker--write-output-to-log-buffer "\n\n" config) response)
(progn (set (make-local-variable 'shell-maker-config) chatgpt-shell--config) (let* ((buffer (current-buffer)) (command (chatgpt-shell--make-curl-request-command-list (let ((request-data ...)) (if (or temperature chatgpt-shell-model-temperature) (progn ...)) request-data))) (config chatgpt-shell--config) (status (progn (shell-maker--write-output-to-log-buffer "// Request\n\n" config) (shell-maker--write-output-to-log-buffer (string-join command " ") config) (shell-maker--write-output-to-log-buffer "\n\n" config) (apply #'call-process (seq-first command) nil buffer nil (cdr command)))) (data (buffer-substring-no-properties (point-min) (point-max))) (response (chatgpt-shell--extract-chatgpt-response data))) (shell-maker--write-output-to-log-buffer (format "// Data (status: %d)\n\n" status) config) (shell-maker--write-output-to-log-buffer data config) (shell-maker--write-output-to-log-buffer "\n\n" config) (shell-maker--write-output-to-log-buffer "// Response\n\n" config) (shell-maker--write-output-to-log-buffer response config) (shell-maker--write-output-to-log-buffer "\n\n" config) response))
(unwind-protect (progn (set (make-local-variable 'shell-maker-config) chatgpt-shell--config) (let* ((buffer (current-buffer)) (command (chatgpt-shell--make-curl-request-command-list (let (...) (if ... ...) request-data))) (config chatgpt-shell--config) (status (progn (shell-maker--write-output-to-log-buffer "// Request\n\n" config) (shell-maker--write-output-to-log-buffer (string-join command " ") config) (shell-maker--write-output-to-log-buffer "\n\n" config) (apply #'call-process (seq-first command) nil buffer nil (cdr command)))) (data (buffer-substring-no-properties (point-min) (point-max))) (response (chatgpt-shell--extract-chatgpt-response data))) (shell-maker--write-output-to-log-buffer (format "// Data (status: %d)\n\n" status) config) (shell-maker--write-output-to-log-buffer data config) (shell-maker--write-output-to-log-buffer "\n\n" config) (shell-maker--write-output-to-log-buffer "// Response\n\n" config) (shell-maker--write-output-to-log-buffer response config) (shell-maker--write-output-to-log-buffer "\n\n" config) response)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (set (make-local-variable 'shell-maker-config) chatgpt-shell--config) (let* ((buffer (current-buffer)) (command (chatgpt-shell--make-curl-request-command-list (let ... ... request-data))) (config chatgpt-shell--config) (status (progn (shell-maker--write-output-to-log-buffer "// Request\n\n" config) (shell-maker--write-output-to-log-buffer ... config) (shell-maker--write-output-to-log-buffer "\n\n" config) (apply ... ... nil buffer nil ...))) (data (buffer-substring-no-properties (point-min) (point-max))) (response (chatgpt-shell--extract-chatgpt-response data))) (shell-maker--write-output-to-log-buffer (format "// Data (status: %d)\n\n" status) config) (shell-maker--write-output-to-log-buffer data config) (shell-maker--write-output-to-log-buffer "\n\n" config) (shell-maker--write-output-to-log-buffer "// Response\n\n" config) (shell-maker--write-output-to-log-buffer response config) (shell-maker--write-output-to-log-buffer "\n\n" config) response)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
(let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (set (make-local-variable 'shell-maker-config) chatgpt-shell--config) (let* ((buffer (current-buffer)) (command (chatgpt-shell--make-curl-request-command-list ...)) (config chatgpt-shell--config) (status (progn ... ... ... ...)) (data (buffer-substring-no-properties ... ...)) (response (chatgpt-shell--extract-chatgpt-response data))) (shell-maker--write-output-to-log-buffer (format "// Data (status: %d)\n\n" status) config) (shell-maker--write-output-to-log-buffer data config) (shell-maker--write-output-to-log-buffer "\n\n" config) (shell-maker--write-output-to-log-buffer "// Response\n\n" config) (shell-maker--write-output-to-log-buffer response config) (shell-maker--write-output-to-log-buffer "\n\n" config) response)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
(if (and callback error-callback) (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (set (make-local-variable 'shell-maker-config) chatgpt-shell--config) (shell-maker-async-shell-command (chatgpt-shell--make-curl-request-command-list (let ... ... request-data)) nil #'chatgpt-shell--extract-chatgpt-response callback error-callback)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (set (make-local-variable 'shell-maker-config) chatgpt-shell--config) (let* ((buffer ...) (command ...) (config chatgpt-shell--config) (status ...) (data ...) (response ...)) (shell-maker--write-output-to-log-buffer (format "// Data (status: %d)\n\n" status) config) (shell-maker--write-output-to-log-buffer data config) (shell-maker--write-output-to-log-buffer "\n\n" config) (shell-maker--write-output-to-log-buffer "// Response\n\n" config) (shell-maker--write-output-to-log-buffer response config) (shell-maker--write-output-to-log-buffer "\n\n" config) response)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))
chatgpt-shell-post-messages([((role . "user") (content . "You're an experienced Python programmer, write a s..."))] nil nil nil nil)
org-babel-execute:chatgpt-shell("You're an experienced Python programmer, write a s..." ((:colname-names) (:rowname-names) (:result-params "replace" "raw") (:result-type . value) (:results . "replace raw") (:exports . "") (:session . "none") (:noweb . "no") (:hlines . "no") (:tangle . "no") (:cache . "yes") (:mkdirp . "yes") (:eval . "never-export") (:version) (:system) (:context) (:temperature)))
funcall(org-babel-execute:chatgpt-shell "You're an experienced Python programmer, write a s..." ((:colname-names) (:rowname-names) (:result-params "replace" "raw") (:result-type . value) (:results . "replace raw") (:exports . "") (:session . "none") (:noweb . "no") (:hlines . "no") (:tangle . "no") (:cache . "yes") (:mkdirp . "yes") (:eval . "never-export") (:version) (:system) (:context) (:temperature)))
(save-current-buffer (funcall cmd body params))
(let ((r (save-current-buffer (funcall cmd body params)))) (if (and (eq (cdr (assq :result-type params)) 'value) (or (member "vector" result-params) (member "table" result-params)) (not (listp r))) (list (list r)) r))
(setq result (let ((r (save-current-buffer (funcall cmd body params)))) (if (and (eq (cdr (assq :result-type params)) 'value) (or (member "vector" result-params) (member "table" result-params)) (not (listp r))) (list (list r)) r)))
(progn (setq exec-start-time (current-time)) (setq result (let ((r (save-current-buffer (funcall cmd body params)))) (if (and (eq (cdr (assq :result-type params)) 'value) (or (member "vector" result-params) (member "table" result-params)) (not (listp r))) (list (list r)) r))))
(let* ((lang (nth 0 info)) (result-params (cdr (assq :result-params params))) (body (org-babel--expand-body info)) (dir (cdr (assq :dir params))) (mkdirp (cdr (assq :mkdirp params))) (default-directory (cond ((not dir) default-directory) ((member mkdirp '("no" "nil" nil)) (file-name-as-directory (expand-file-name dir))) (t (let ((d ...)) (make-directory d 'parents) d)))) (cmd (intern (concat "org-babel-execute:" lang))) result exec-start-time) (if (fboundp cmd) nil (error "No org-babel-execute function for %s!" lang)) (message "Executing %s %s %s..." (capitalize lang) (cond ((eq executor-type 'src-block) (let nil "code block")) ((eq executor-type 'inline-src-block) (let nil "inline code block")) ((eq executor-type 'babel-call) (let nil "call")) ((eq executor-type 'inline-babel-call) (let nil "inline call")) (t (let ((e executor-type)) (symbol-name e)))) (let ((name (nth 4 info))) (if name (format "(%s)" name) (format "at position %S" (nth 5 info))))) (progn (setq exec-start-time (current-time)) (setq result (let ((r (save-current-buffer (funcall cmd body params)))) (if (and (eq (cdr ...) 'value) (or (member "vector" result-params) (member "table" result-params)) (not (listp r))) (list (list r)) r)))) (let ((file (and (member "file" result-params) (cdr (assq :file params))))) (if file (progn (if (and result (not (or ... ...))) (progn (let (... ...) (unwind-protect ... ...)) (if (assq :file-mode params) (progn ...)))) (setq result file))) (let ((post (cdr (assq :post params)))) (if post (progn (let ((*this* ...)) (setq result (org-babel-ref-resolve post)) (if file (progn ...)))))) (if (member "none" result-params) nil (org-babel-insert-result result result-params info new-hash lang (time-subtract (current-time) exec-start-time)))) (run-hooks 'org-babel-after-execute-hook) result)
(cond (current-cache (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " \11") (let ((result (org-babel-read-result))) (message (format "Cached: %s" (replace-regexp-in-string "%" "%%" (format "%S" result)))) result))) ((org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (result-params (cdr (assq :result-params params))) (body (org-babel--expand-body info)) (dir (cdr (assq :dir params))) (mkdirp (cdr (assq :mkdirp params))) (default-directory (cond ((not dir) default-directory) ((member mkdirp ...) (file-name-as-directory ...)) (t (let ... ... d)))) (cmd (intern (concat "org-babel-execute:" lang))) result exec-start-time) (if (fboundp cmd) nil (error "No org-babel-execute function for %s!" lang)) (message "Executing %s %s %s..." (capitalize lang) (cond ((eq executor-type 'src-block) (let nil "code block")) ((eq executor-type 'inline-src-block) (let nil "inline code block")) ((eq executor-type 'babel-call) (let nil "call")) ((eq executor-type 'inline-babel-call) (let nil "inline call")) (t (let (...) (symbol-name e)))) (let ((name (nth 4 info))) (if name (format "(%s)" name) (format "at position %S" (nth 5 info))))) (progn (setq exec-start-time (current-time)) (setq result (let ((r ...)) (if (and ... ... ...) (list ...) r)))) (let ((file (and (member "file" result-params) (cdr ...)))) (if file (progn (if (and result ...) (progn ... ...)) (setq result file))) (let ((post (cdr ...))) (if post (progn (let ... ... ...)))) (if (member "none" result-params) nil (org-babel-insert-result result result-params info new-hash lang (time-subtract (current-time) exec-start-time)))) (run-hooks 'org-babel-after-execute-hook) result)))
(let* ((params (nth 2 info)) (cache (let ((c (cdr (assq :cache params)))) (and (not arg) c (string= "yes" c)))) (new-hash (and cache (org-babel-sha1-hash info :eval))) (old-hash (and cache (org-babel-current-result-hash))) (current-cache (and new-hash (equal new-hash old-hash)))) (cond (current-cache (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " \11") (let ((result (org-babel-read-result))) (message (format "Cached: %s" (replace-regexp-in-string "%" "%%" ...))) result))) ((org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (result-params (cdr (assq :result-params params))) (body (org-babel--expand-body info)) (dir (cdr (assq :dir params))) (mkdirp (cdr (assq :mkdirp params))) (default-directory (cond (... default-directory) (... ...) (t ...))) (cmd (intern (concat "org-babel-execute:" lang))) result exec-start-time) (if (fboundp cmd) nil (error "No org-babel-execute function for %s!" lang)) (message "Executing %s %s %s..." (capitalize lang) (cond ((eq executor-type ...) (let nil "code block")) ((eq executor-type ...) (let nil "inline code block")) ((eq executor-type ...) (let nil "call")) ((eq executor-type ...) (let nil "inline call")) (t (let ... ...))) (let ((name ...)) (if name (format "(%s)" name) (format "at position %S" ...)))) (progn (setq exec-start-time (current-time)) (setq result (let (...) (if ... ... r)))) (let ((file (and ... ...))) (if file (progn (if ... ...) (setq result file))) (let ((post ...)) (if post (progn ...))) (if (member "none" result-params) nil (org-babel-insert-result result result-params info new-hash lang (time-subtract ... exec-start-time)))) (run-hooks 'org-babel-after-execute-hook) result))))
(progn (let* ((c (nthcdr 2 info))) (setcar c (org-babel-process-params (car c)))) (let* ((params (nth 2 info)) (cache (let ((c (cdr ...))) (and (not arg) c (string= "yes" c)))) (new-hash (and cache (org-babel-sha1-hash info :eval))) (old-hash (and cache (org-babel-current-result-hash))) (current-cache (and new-hash (equal new-hash old-hash)))) (cond (current-cache (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " \11") (let ((result ...)) (message (format "Cached: %s" ...)) result))) ((org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (result-params (cdr ...)) (body (org-babel--expand-body info)) (dir (cdr ...)) (mkdirp (cdr ...)) (default-directory (cond ... ... ...)) (cmd (intern ...)) result exec-start-time) (if (fboundp cmd) nil (error "No org-babel-execute function for %s!" lang)) (message "Executing %s %s %s..." (capitalize lang) (cond (... ...) (... ...) (... ...) (... ...) (t ...)) (let (...) (if name ... ...))) (progn (setq exec-start-time (current-time)) (setq result (let ... ...))) (let ((file ...)) (if file (progn ... ...)) (let (...) (if post ...)) (if (member "none" result-params) nil (org-babel-insert-result result result-params info new-hash lang ...))) (run-hooks 'org-babel-after-execute-hook) result)))))
(if (org-babel-check-evaluate info) (progn (let* ((c (nthcdr 2 info))) (setcar c (org-babel-process-params (car c)))) (let* ((params (nth 2 info)) (cache (let ((c ...)) (and (not arg) c (string= "yes" c)))) (new-hash (and cache (org-babel-sha1-hash info :eval))) (old-hash (and cache (org-babel-current-result-hash))) (current-cache (and new-hash (equal new-hash old-hash)))) (cond (current-cache (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " \11") (let (...) (message ...) result))) ((org-babel-confirm-evaluate info) (let* ((lang ...) (result-params ...) (body ...) (dir ...) (mkdirp ...) (default-directory ...) (cmd ...) result exec-start-time) (if (fboundp cmd) nil (error "No org-babel-execute function for %s!" lang)) (message "Executing %s %s %s..." (capitalize lang) (cond ... ... ... ... ...) (let ... ...)) (progn (setq exec-start-time ...) (setq result ...)) (let (...) (if file ...) (let ... ...) (if ... nil ...)) (run-hooks 'org-babel-after-execute-hook) result))))))
(let* ((org-babel-current-src-block-location (or org-babel-current-src-block-location (nth 5 info) (org-babel-where-is-src-block-head))) (info (if info (copy-tree info) (org-babel-get-src-block-info))) (executor-type (or executor-type (let* ((val (and org-babel-current-src-block-location ...))) (cond ((eql val 115) (let nil ...)) ((eql val 99) (let nil ...)) ((eql val 35) (let nil ...)) (t (let nil ...))))))) (let* ((c (nthcdr 2 info))) (setcar c (org-babel-merge-params (car c) params))) (if (org-babel-check-evaluate info) (progn (let* ((c (nthcdr 2 info))) (setcar c (org-babel-process-params (car c)))) (let* ((params (nth 2 info)) (cache (let (...) (and ... c ...))) (new-hash (and cache (org-babel-sha1-hash info :eval))) (old-hash (and cache (org-babel-current-result-hash))) (current-cache (and new-hash (equal new-hash old-hash)))) (cond (current-cache (save-excursion (goto-char ...) (forward-line) (skip-chars-forward " \11") (let ... ... result))) ((org-babel-confirm-evaluate info) (let* (... ... ... ... ... ... ... result exec-start-time) (if ... nil ...) (message "Executing %s %s %s..." ... ... ...) (progn ... ...) (let ... ... ... ...) (run-hooks ...) result)))))))
org-babel-execute-src-block((4) ("chatgpt-shell" "You're an experienced Python programmer, write a s..." ((:colname-names) (:rowname-names) (:result-params "raw" "replace") (:result-type . value) (:results . "raw replace") (:exports . "") (:temperature) (:context) (:system) (:version) (:eval . "never-export") (:mkdirp . "yes") (:cache . "yes") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:session . "none")) "" nil 14053 "(ref:%s)"))
(if org-babel-no-eval-on-ctrl-c-ctrl-c nil (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg (org-babel-get-src-block-info nil context)))
(let nil (if org-babel-no-eval-on-ctrl-c-ctrl-c nil (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg (org-babel-get-src-block-info nil context))))
(cond ((memq type '(src-block inline-src-block)) (let nil (if org-babel-no-eval-on-ctrl-c-ctrl-c nil (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg (org-babel-get-src-block-info nil context))))) ((org-match-line "[ \11]*$") (let nil (or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) (user-error (substitute-command-keys "`\\[org-ctrl-c-ctrl-c]' can do nothing useful here"))))) ((memq type '(inline-babel-call babel-call)) (let nil (let ((info (org-babel-lob-get-info context))) (if info (progn (org-babel-execute-src-block nil info nil type)))))) ((eq type 'clock) (let nil (if (org-at-timestamp-p 'lax) (org-timestamp-change 0 'day) (org-clock-update-time-maybe)))) ((eq type 'dynamic-block) (let nil (save-excursion (goto-char (org-element-property :post-affiliated context)) (org-update-dblock)))) ((eq type 'footnote-definition) (let nil (goto-char (org-element-property :post-affiliated context)) (call-interactively 'org-footnote-action))) ((eq type 'footnote-reference) (let nil (call-interactively #'org-footnote-action))) ((memq type '(inlinetask headline)) (let nil (save-excursion (goto-char (org-element-property :begin context)) (call-interactively #'org-set-tags-command)))) ((eq type 'item) (let nil (if (or radio-list-p (and (boundp org-list-checkbox-radio-mode) org-list-checkbox-radio-mode)) (org-toggle-radio-button arg) (let* ((box (org-element-property :checkbox context)) (struct (org-element-property :structure context)) (old-struct (copy-tree struct)) (parents (org-list-parents-alist struct)) (prevs (org-list-prevs-alist struct)) (orderedp (org-not-nil ...))) (org-list-set-checkbox (org-element-property :begin context) struct (cond (... "[-]") (... "[ ]") (... nil) (... "[ ]") (t "[X]"))) (org-list-struct-fix-ind struct parents 2) (org-list-struct-fix-item-end struct) (org-list-struct-fix-bul struct prevs) (org-list-struct-fix-ind struct parents) (let ((block-item ...)) (if (and box ...) (if ... ... ...) (org-list-struct-apply-struct struct old-struct) (org-update-checkbox-count-maybe)) (if block-item (progn ...))))))) ((eq type 'plain-list) (let nil (if (or radio-list-p (and (boundp org-list-checkbox-radio-mode) org-list-checkbox-radio-mode)) (org-toggle-radio-button arg) (let* ((begin (org-element-property :contents-begin context)) (struct (org-element-property :structure context)) (old-struct (copy-tree struct)) (first-box (save-excursion ... ... ...)) (new-box (cond ... ... ... ...))) (cond (arg (let ... ...)) ((and first-box ...) (org-list-set-checkbox begin struct new-box))) (if (equal (org-list-write-struct struct ... old-struct) old-struct) (progn (message "Cannot update this checkbox"))) (org-update-checkbox-count-maybe))))) ((eq type 'keyword) (let nil (let ((org-inhibit-startup-visibility-stuff t) (org-startup-align-all-tables nil)) (if (boundp 'org-table-coordinate-overlays) (progn (mapc #'delete-overlay org-table-coordinate-overlays) (setq org-table-coordinate-overlays nil))) (let* ((--regions (org-fold-core-get-regions :with-markers ...))) (unwind-protect (progn (org-mode-restart)) (save-excursion (save-restriction ... ... ...))))) (message "Local setup has been refreshed"))) ((memq type '(node-property property-drawer)) (let nil (call-interactively #'org-property-action))) ((eq type 'radio-target) (let nil (call-interactively #'org-update-radio-target-regexp))) ((eq type 'statistics-cookie) (let nil (call-interactively #'org-update-statistics-cookies))) ((memq type '(table-row table-cell table)) (let nil (cond ((and (org-match-line "[ \11]*#\\+plot:") (< (point) (org-element-property :post-affiliated context))) (org-plot/gnuplot)) ((eq (org-element-property :type context) 'table.el) (message "%s" (substitute-command-keys "\\<org-mode-map>Use `\\[org-edit-special]' to edit t..."))) ((or (eq type 'table) (and (eq type ...) (= ... ...))) (save-excursion (if (org-at-TBLFM-p) (progn ... ...) (goto-char ...) (org-call-with-arg ... ...) (orgtbl-send-table ...)))) (t (org-table-maybe-eval-formula) (cond (arg (call-interactively ...)) ((org-table-maybe-recalculate-line)) (t (org-table-align))))))) ((eq type 'timestamp) (funcall pcase-1)) ((eq type 'planning) (cond ((org-at-timestamp-p 'lax) (funcall pcase-1)) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) 'nil) (t (funcall pcase-0)))) ((null type) (cond ((org-at-heading-p) (let nil (call-interactively #'org-set-tags-command))) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) 'nil) (t (funcall pcase-0)))) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) 'nil) (t (funcall pcase-0)))
(let* ((pcase-1 #'(lambda nil (org-timestamp-change 0 'day))) (pcase-0 #'(lambda nil (user-error (substitute-command-keys "`\\[org-ctrl-c-ctrl-c]' can do nothing useful here"))))) (cond ((memq type '(src-block inline-src-block)) (let nil (if org-babel-no-eval-on-ctrl-c-ctrl-c nil (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg (org-babel-get-src-block-info nil context))))) ((org-match-line "[ \11]*$") (let nil (or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) (user-error (substitute-command-keys "`\\[org-ctrl-c-ctrl-c]' can do nothing useful here"))))) ((memq type '(inline-babel-call babel-call)) (let nil (let ((info (org-babel-lob-get-info context))) (if info (progn (org-babel-execute-src-block nil info nil type)))))) ((eq type 'clock) (let nil (if (org-at-timestamp-p 'lax) (org-timestamp-change 0 'day) (org-clock-update-time-maybe)))) ((eq type 'dynamic-block) (let nil (save-excursion (goto-char (org-element-property :post-affiliated context)) (org-update-dblock)))) ((eq type 'footnote-definition) (let nil (goto-char (org-element-property :post-affiliated context)) (call-interactively 'org-footnote-action))) ((eq type 'footnote-reference) (let nil (call-interactively #'org-footnote-action))) ((memq type '(inlinetask headline)) (let nil (save-excursion (goto-char (org-element-property :begin context)) (call-interactively #'org-set-tags-command)))) ((eq type 'item) (let nil (if (or radio-list-p (and (boundp org-list-checkbox-radio-mode) org-list-checkbox-radio-mode)) (org-toggle-radio-button arg) (let* ((box ...) (struct ...) (old-struct ...) (parents ...) (prevs ...) (orderedp ...)) (org-list-set-checkbox (org-element-property :begin context) struct (cond ... ... ... ... ...)) (org-list-struct-fix-ind struct parents 2) (org-list-struct-fix-item-end struct) (org-list-struct-fix-bul struct prevs) (org-list-struct-fix-ind struct parents) (let (...) (if ... ... ... ...) (if block-item ...)))))) ((eq type 'plain-list) (let nil (if (or radio-list-p (and (boundp org-list-checkbox-radio-mode) org-list-checkbox-radio-mode)) (org-toggle-radio-button arg) (let* ((begin ...) (struct ...) (old-struct ...) (first-box ...) (new-box ...)) (cond (arg ...) (... ...)) (if (equal ... old-struct) (progn ...)) (org-update-checkbox-count-maybe))))) ((eq type 'keyword) (let nil (let ((org-inhibit-startup-visibility-stuff t) (org-startup-align-all-tables nil)) (if (boundp 'org-table-coordinate-overlays) (progn (mapc ... org-table-coordinate-overlays) (setq org-table-coordinate-overlays nil))) (let* ((--regions ...)) (unwind-protect (progn ...) (save-excursion ...)))) (message "Local setup has been refreshed"))) ((memq type '(node-property property-drawer)) (let nil (call-interactively #'org-property-action))) ((eq type 'radio-target) (let nil (call-interactively #'org-update-radio-target-regexp))) ((eq type 'statistics-cookie) (let nil (call-interactively #'org-update-statistics-cookies))) ((memq type '(table-row table-cell table)) (let nil (cond ((and (org-match-line "[ \11]*#\\+plot:") (< ... ...)) (org-plot/gnuplot)) ((eq (org-element-property :type context) 'table.el) (message "%s" (substitute-command-keys "\\<org-mode-map>Use `\\[org-edit-special]' to edit t..."))) ((or (eq type ...) (and ... ...)) (save-excursion (if ... ... ... ... ...))) (t (org-table-maybe-eval-formula) (cond (arg ...) (...) (t ...)))))) ((eq type 'timestamp) (funcall pcase-1)) ((eq type 'planning) (cond ((org-at-timestamp-p 'lax) (funcall pcase-1)) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) 'nil) (t (funcall pcase-0)))) ((null type) (cond ((org-at-heading-p) (let nil (call-interactively #'org-set-tags-command))) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) 'nil) (t (funcall pcase-0)))) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) 'nil) (t (funcall pcase-0))))
(let* ((context (org-element-lineage (org-element-context) '(babel-call clock dynamic-block footnote-definition footnote-reference inline-babel-call inline-src-block inlinetask item keyword node-property paragraph plain-list planning property-drawer radio-target src-block statistics-cookie table table-cell table-row timestamp) t)) (radio-list-p (org-at-radio-list-p)) (type (org-element-type context))) (if (eq type 'paragraph) (progn (let ((parent (org-element-property :parent context))) (if (and (eq (org-element-type parent) 'item) (= (line-beginning-position) (org-element-property :begin parent))) (progn (setq context parent) (setq type 'item)))))) (let* ((pcase-1 #'(lambda nil (org-timestamp-change 0 'day))) (pcase-0 #'(lambda nil (user-error (substitute-command-keys "`\\[org-ctrl-c-ctrl-c]' can do nothing useful here"))))) (cond ((memq type '(src-block inline-src-block)) (let nil (if org-babel-no-eval-on-ctrl-c-ctrl-c nil (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg (org-babel-get-src-block-info nil context))))) ((org-match-line "[ \11]*$") (let nil (or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) (user-error (substitute-command-keys "`\\[org-ctrl-c-ctrl-c]' can do nothing useful here"))))) ((memq type '(inline-babel-call babel-call)) (let nil (let ((info ...)) (if info (progn ...))))) ((eq type 'clock) (let nil (if (org-at-timestamp-p 'lax) (org-timestamp-change 0 'day) (org-clock-update-time-maybe)))) ((eq type 'dynamic-block) (let nil (save-excursion (goto-char (org-element-property :post-affiliated context)) (org-update-dblock)))) ((eq type 'footnote-definition) (let nil (goto-char (org-element-property :post-affiliated context)) (call-interactively 'org-footnote-action))) ((eq type 'footnote-reference) (let nil (call-interactively #'org-footnote-action))) ((memq type '(inlinetask headline)) (let nil (save-excursion (goto-char (org-element-property :begin context)) (call-interactively #'org-set-tags-command)))) ((eq type 'item) (let nil (if (or radio-list-p (and ... org-list-checkbox-radio-mode)) (org-toggle-radio-button arg) (let* (... ... ... ... ... ...) (org-list-set-checkbox ... struct ...) (org-list-struct-fix-ind struct parents 2) (org-list-struct-fix-item-end struct) (org-list-struct-fix-bul struct prevs) (org-list-struct-fix-ind struct parents) (let ... ... ...))))) ((eq type 'plain-list) (let nil (if (or radio-list-p (and ... org-list-checkbox-radio-mode)) (org-toggle-radio-button arg) (let* (... ... ... ... ...) (cond ... ...) (if ... ...) (org-update-checkbox-count-maybe))))) ((eq type 'keyword) (let nil (let ((org-inhibit-startup-visibility-stuff t) (org-startup-align-all-tables nil)) (if (boundp ...) (progn ... ...)) (let* (...) (unwind-protect ... ...))) (message "Local setup has been refreshed"))) ((memq type '(node-property property-drawer)) (let nil (call-interactively #'org-property-action))) ((eq type 'radio-target) (let nil (call-interactively #'org-update-radio-target-regexp))) ((eq type 'statistics-cookie) (let nil (call-interactively #'org-update-statistics-cookies))) ((memq type '(table-row table-cell table)) (let nil (cond ((and ... ...) (org-plot/gnuplot)) ((eq ... ...) (message "%s" ...)) ((or ... ...) (save-excursion ...)) (t (org-table-maybe-eval-formula) (cond ... ... ...))))) ((eq type 'timestamp) (funcall pcase-1)) ((eq type 'planning) (cond ((org-at-timestamp-p 'lax) (funcall pcase-1)) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) 'nil) (t (funcall pcase-0)))) ((null type) (cond ((org-at-heading-p) (let nil (call-interactively ...))) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) 'nil) (t (funcall pcase-0)))) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) 'nil) (t (funcall pcase-0)))))
(cond ((and (boundp 'org-columns-overlays) org-columns-overlays) (org-columns-quit)) ((or (and (boundp 'org-clock-overlays) org-clock-overlays) org-occur-highlights) (if (boundp 'org-clock-overlays) (progn (org-clock-remove-overlays))) (org-remove-occur-highlights) (message "Temporary highlights/overlays removed from current...")) ((and (local-variable-p 'org-finish-function) (fboundp org-finish-function)) (funcall org-finish-function)) ((org-babel-hash-at-point)) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook)) (t (let* ((context (org-element-lineage (org-element-context) '(babel-call clock dynamic-block footnote-definition footnote-reference inline-babel-call inline-src-block inlinetask item keyword node-property paragraph plain-list planning property-drawer radio-target src-block statistics-cookie table table-cell table-row timestamp) t)) (radio-list-p (org-at-radio-list-p)) (type (org-element-type context))) (if (eq type 'paragraph) (progn (let ((parent ...)) (if (and ... ...) (progn ... ...))))) (let* ((pcase-1 #'(lambda nil ...)) (pcase-0 #'(lambda nil ...))) (cond ((memq type '...) (let nil (if org-babel-no-eval-on-ctrl-c-ctrl-c nil ... ...))) ((org-match-line "[ \11]*$") (let nil (or ... ...))) ((memq type '...) (let nil (let ... ...))) ((eq type 'clock) (let nil (if ... ... ...))) ((eq type 'dynamic-block) (let nil (save-excursion ... ...))) ((eq type 'footnote-definition) (let nil (goto-char ...) (call-interactively ...))) ((eq type 'footnote-reference) (let nil (call-interactively ...))) ((memq type '...) (let nil (save-excursion ... ...))) ((eq type 'item) (let nil (if ... ... ...))) ((eq type 'plain-list) (let nil (if ... ... ...))) ((eq type 'keyword) (let nil (let ... ... ...) (message "Local setup has been refreshed"))) ((memq type '...) (let nil (call-interactively ...))) ((eq type 'radio-target) (let nil (call-interactively ...))) ((eq type 'statistics-cookie) (let nil (call-interactively ...))) ((memq type '...) (let nil (cond ... ... ... ...))) ((eq type 'timestamp) (funcall pcase-1)) ((eq type 'planning) (cond (... ...) (... ...) (t ...))) ((null type) (cond (... ...) (... ...) (t ...))) ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook) 'nil) (t (funcall pcase-0)))))))
org-ctrl-c-ctrl-c((4))
funcall-interactively(org-ctrl-c-ctrl-c (4))
call-interactively(org-ctrl-c-ctrl-c nil nil)
command-execute(org-ctrl-c-ctrl-c)
Try again (made another change), it should output <nil>
for those cases.
Tested on latest code. Works fine now. Thanks a lot, @xenodium
Thank you for the pull request. I've addressed the same goal using the same logging mechanism used for async cases. Please give that a try.