nobiot / org-transclusion

Emacs package to enable transclusion with Org Mode
https://nobiot.github.io/org-transclusion/
GNU General Public License v3.0
942 stars 48 forks source link

Support M-left and M-right to promote/demote transcluded headings #135

Open chrisbarrett opened 2 years ago

chrisbarrett commented 2 years ago

I find it convenient to be able to promote and demote transcluded headlines using out-of-the-box org-mode key commands. I've got this lisp in my config, but I thought it might be a useful thing to upstream:

(defun config-org-at-transclusion-keyword-p ()
  (when-let* ((elm (org-element-at-point)))
    (and (string= "keyword" (org-element-type elm))
         (string= "TRANSCLUDE" (org-element-property :key elm)))))

(defun config-org-transclusion-promote ()
  (when (require 'org-transclusion nil t)
    (cond
     ((org-transclusion-within-transclusion-p)
      (org-transclusion-promote-subtree))
     ((config-org-at-transclusion-keyword-p)
      (org-transclusion-add)))))

(defun config-org-transclusion-demote ()
  (when (require 'org-transclusion nil t)
    (cond
     ((org-transclusion-within-transclusion-p)
      (org-transclusion-demote-subtree))
     ((config-org-at-transclusion-keyword-p)
      (org-transclusion-add)))))

(add-hook 'org-metaleft-hook #'config-org-transclusion-promote)
(add-hook 'org-metaright-hook #'config-org-transclusion-demote)

Let me know if you're interested in a PR for this functionality. Feel free to close if you don't like the idea. :)

nobiot commented 2 years ago

Certainly interested. Thank you :) But before asking for a PR, I need to inform you about FSF paperwork. Since this package is available on ELPA, significant contribution (more than 15 lines of code) requires FSF paperwork as described in Contributing section of README.

Have you done this, or willing to do it?

I also wonder if the hook should be enabled/disabled locally, together with org-transclusion-mode, rather than globally enabled when loading the package.

nobiot commented 2 years ago

Certainly interested. Thank you :) But before asking for a PR, since this package is available on ELPA significant contribution (more than 15 lines of code) requires FSF paperwork as described in Contributing section of README.

Have you done this, or willing to do it?

I also wonder if the hook should be enabled/disabled locally, together with org-transclusion-mode, rather than globally enabled when loading the package.

nobiot commented 2 years ago

Certainly interested. Thank you :) But before asking for a PR, since this package is available on ELPA significant contribution (more than 15 lines of code) requires FSF paperwork as described in Contributing section of README.

Have you done this, or willing to do it?

I also wonder if the hook should be enabled/disabled locally, together with org-transclusion-mode, rather than globally enabled when loading the package.

chrisbarrett commented 2 years ago

Yeah, it would probably be smart to add the hooks locally locally inside the body of org-transclusion-mode. 👍

I haven't signed FSF papers, but I'll look into it and get back to you.

Edit: copyright assignment request sent to FSF

chrisbarrett commented 2 years ago

Hello, just circling back--FSF papers have been signed. :) Let me know if you want me to flick you a copy, and whether you're happy to take this code and run with it or whether you want a PR.

nobiot commented 2 years ago

Thank you! A PR would be great.

Could I also ask you to:

  1. Update NEWS file (add it to the top of the file)
  2. (Optionally) Advise (if you think the new feature should need some additional description) a short paragraph(s) to describe the new feature in the user manual