org-transclusion icon indicating copy to clipboard operation
org-transclusion copied to clipboard

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

Open chrisbarrett opened this issue 3 years ago • 6 comments

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. :)

chrisbarrett avatar Feb 22 '22 08:02 chrisbarrett

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 avatar Feb 24 '22 16:02 nobiot

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 avatar Feb 24 '22 16:02 nobiot

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 avatar Feb 24 '22 16:02 nobiot

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 avatar Feb 24 '22 23:02 chrisbarrett

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.

chrisbarrett avatar May 03 '22 00:05 chrisbarrett

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

nobiot avatar May 07 '22 06:05 nobiot