Edit a source block with its name shown in org

My preference is to rely upon heading property inheritance to define source block
names. That way, you can just do your work knowing “where” you are working and
keep it simple by not having to name everything. That was just fine until I
wrote a document where I needed to name each source block.

It gets easy to forget the source block’s name. Not the end of the world, but very nice to know.

(defun gcr/org-edit-src-code-plus-name ()
  "Edit the well-described source code block.

Attribution: URL `https://lists.gnu.org/archive/html/emacs-orgmode/2014-09/msg00778.html'"
  (interactive)
  (let* ((eop  (org-element-at-point))
         (name (or (org-element-property :name (org-element-context eop))
                  "ॐ"))
         (lang (org-element-property :language eop))
         (buff-name (concat "*Org Src " name "[" lang "]*")))
    (org-edit-src-code nil nil buff-name)))

One thought on “Edit a source block with its name shown in org”

Leave a Reply

Your email address will not be published. Required fields are marked *