r/emacs•
mankofffoo

How can I edit magit forge issue comments in Org Mode?

I'd like to use Org, not Markdown, to write and edit GitHub issues. I have something sort-of working. I advise `forge-create-post` to use Org Mode, and capture `C-u C-c- C-c` to convert the buffer to gfm and submit it. However, I'm getting this error:

forge-post-submit: forge--submit-post-function is nil

Here is the code I've written so far:

​

(defun my/forge-submit-from-org nil
  (interactive)
  (if (equal current-prefix-arg nil)
      (org-ctrl-c-ctrl-c)
    (progn
      (org-export-to-buffer 'gfm (buffer-name))
      (forge-post-mode)
      (forge-post-submit)
      )))
    
(defun my/forge-create-post-mode nil
  (interactive)
  (org-mode)
  (use-local-map (copy-keymap org-mode-map))
  (local-set-key (kbd "C-c C-c") 'my/forge-submit-from-org))

(advice-add 'forge-create-post :after #'my/forge-create-post-mode)

Posted May 31, 2023, 5:12 PM UTC

57
github-alphapapa•

Activating a major mode in a buffer, like org-mode, kills all of the previous mode's buffer-local variables, including forge--submit-post-function.

4
mankofffooOP•

Makes sense. Is there a way I can store everything before activating org-mode and then restore it later? I tried copying chunks of the forge-create-issue function that I'm advising to reset those vars, but it didn't work.

1
yantar92•

It might be not safe, but you can mark some local variables permanent. See kill-all-local-variables docstring.

1
mankofffooOP•

Any other way that might be safer to re-initialize the variable used here ? https://github.com/magit/forge/blob/ec68fcd778f6b3dc6100498aea790457d2fc98f6/lisp/forge-commands.el#L442-L472

1
yantar92•

I doubt you can do much safely here. Another way could be overriding forge-post-mode with org-mode.

1