{"id":20120735,"url":"https://github.com/jmromer/yankee.el","last_synced_at":"2025-09-06T11:33:46.777Z","repository":{"id":21355651,"uuid":"92133480","full_name":"jmromer/yankee.el","owner":"jmromer","description":"Yank your code in VCS-annotated GFM or Org-mode source blocks","archived":false,"fork":false,"pushed_at":"2023-03-26T19:15:33.000Z","size":64,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-13T07:13:18.183Z","etag":null,"topics":["emacs","emacs-lisp","github-flavored-markdown","markdown","org-mode"],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmromer.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-23T05:37:01.000Z","updated_at":"2021-10-12T16:17:14.000Z","dependencies_parsed_at":"2022-08-08T09:30:15.631Z","dependency_job_id":null,"html_url":"https://github.com/jmromer/yankee.el","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmromer%2Fyankee.el","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmromer%2Fyankee.el/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmromer%2Fyankee.el/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmromer%2Fyankee.el/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmromer","download_url":"https://codeload.github.com/jmromer/yankee.el/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241564538,"owners_count":19982960,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emacs","emacs-lisp","github-flavored-markdown","markdown","org-mode"],"created_at":"2024-11-13T19:22:44.999Z","updated_at":"2025-03-02T20:17:16.402Z","avatar_url":"https://github.com/jmromer.png","language":"Emacs Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"* yankee.el\n\nYankee extends ~copy-as-format~ to provide a function for yanking source blocks\nin Emacs with helpful annotations to help readers gain more context:\n\n- ~yankee-yank~\n\nThese are especially useful when composing issues and pull/merge requests on\nGitHub / GitLab / Bitbucket, but have broader utility as well. See the full list\nof supported formats (and how to add your own) at [[https://github.com/sshaw/copy-as-format][~copy-as-format~]].\n\nIf the yanked region is in a project, its path relative to the project root will\nbe used to annotate the code block with a comment that including the selected\nline numbers.\n\nIf not in a project, an abbreviated absolute path will be included instead.\n\nAdditionally, if the buffer being yanked from is backed by a file under version\ncontrol, a commit ref will be included.\n\n# And lastly, if the yanked region is committed to version control, a hyperlink to\n# the selection, at the correct commit ref, will be included as well. (Currently,\n# only Git is supported.)\n\n** GitHub-flavored Markdown\n\n#+BEGIN_SRC markdown\n```emacs-lisp\n;; yankee.el L158-L163 (ea278931)\n\n(defun yankee/current-commit-ref ()\n  \"The current commit's SHA, if under version control.\nCurrently only supports Git.\"\n  (if (equal 'Git (vc-backend (buffer-file-name)))\n      (substring (shell-command-to-string \"git rev-parse HEAD\") 0 8)\n    nil))\n```\n\u003csup\u003e\n  \u003ca href=\"https://github.com/jmromer/yankee.el/blob/ea278931/yankee.el#L158-L163\"\u003e\n    yankee.el#L158-L163 (ea278931)\n  \u003c/a\u003e\n\u003c/sup\u003e\n#+END_SRC\n\nwhich produces this [[https://github.com/jmromer/yankee.el/pull/1#user-content-gfm][output]]:\n\n#+CAPTION: yank-as-gfm-code-block\n#+NAME: fig: gfm\n[[https://cloud.githubusercontent.com/assets/4433943/26434857/271536bc-40d9-11e7-93f9-fe0988975259.png]]\n\n** GitHub-flavored Markdown (foldable)\n\n(The summary line is customizable at runtime)\n\n#+BEGIN_SRC markdown\n\u003cdetails\u003e\n\u003csummary\u003eyankee/current-commit-ref\u003c/summary\u003e\n\n```emacs-lisp\n;; yankee.el L158-L163 (ea278931)\n\n(defun yankee/current-commit-ref ()\n  \"The current commit's SHA, if under version control.\nCurrently only supports Git.\"\n  (if (equal 'Git (vc-backend (buffer-file-name)))\n      (substring (shell-command-to-string \"git rev-parse HEAD\") 0 8)\n    nil))\n```\n\u003csup\u003e\n  \u003ca href=https://github.com/jmromer/yankee.el/blob/ea278931/yankee.el#L158-L163\"\u003e\n    yankee.el#L158-L163 (ea278931)\n  \u003c/a\u003e\n\u003c/sup\u003e\n\u003c/details\u003e\n#+END_SRC\n\nwhich produces this [[https://github.com/jmromer/yankee.el/pull/1#user-content-gfm-foldable][output]]:\n\n#+CAPTION: yank-as-gfm-code-block-foldable\n#+NAME: fig: gfm-foldable\n[[https://cloud.githubusercontent.com/assets/4433943/26434858/271fbf6a-40d9-11e7-91fb-66511c42cdc2.gif]]\n\n** Org mode\n\n   NB: The `BEGIN_SRC` tag is intentionally broken here for display purposes.\n\n#+BEGIN_SRC org\n#+BEGIN SRC emacs-lisp\n;; yankee.el L158-L163 (517300b3)\n\n(defun yankee/current-commit-ref ()\n  \"The current commit's SHA, if under version control.\nCurrently only supports Git.\"\n  (if (equal 'Git (vc-backend (buffer-file-name)))\n      (substring (shell-command-to-string \"git rev-parse HEAD\") 0 8)\n    nil))\n#+END SRC\n[[https://github.com/jmromer/yankee.el/blob/517300b3/yankee.el#L158-L163][yankee.el#L158-L163 (517300b3)]]\n#+END_SRC\n\nwhich produces this output:\n\n#+BEGIN_SRC emacs-lisp\n;; yankee.el L158-L163 (517300b3)\n\n(defun yankee/current-commit-ref ()\n  \"The current commit's SHA, if under version control.\nCurrently only supports Git.\"\n  (if (equal 'Git (vc-backend (buffer-file-name)))\n      (substring (shell-command-to-string \"git rev-parse HEAD\") 0 8)\n    nil))\n#+END_SRC\n[[https://github.com/jmromer/yankee.el/blob/517300b3/yankee.el#L158-L163][yankee.el#L158-L163 (517300b3)]]\n\n** Jira\n\n#+BEGIN_SRC\n{code:python}\n# testproj/articles/models.py L4-L9 (ee46f59fb1)\n\nclass Article(models.Model):\n    title = models.CharField(help_text=\"title model help_text\", max_length=255, blank=False, unique=True)\n    body = models.TextField(help_text=\"article model help_text\", max_length=5000, blank=False)\n    slug = models.SlugField(help_text=\"slug model help_text\", unique=True, blank=True)\n    date_created = models.DateTimeField(auto_now_add=True)\n    date_modified = models.DateTimeField(auto_now=True)\n{code}\n\n[testproj/articles/models.py#L4-L9 (ee46f59fb1)|https://github.com/axnsan12/drf-yasg/blob/ee46f59fb1/testproj/articles/models.py#L4-L9]\n#+END_SRC\n\nwhich renders as follows:\n\n#+CAPTION: yank-as-jira-code-block\n#+NAME: fig: jira\n[[https://user-images.githubusercontent.com/4433943/39444725-b02dadb2-4c86-11e8-9a04-b03e6fd4503e.png][https://user-images.githubusercontent.com/4433943/39444725-b02dadb2-4c86-11e8-9a04-b03e6fd4503e.png]]\n\n** Demo\n\n(Click to view animated)\n\n#+CAPTION: yankee.el demo\n#+NAME: fig: yankee-demo\n[[https://cloud.githubusercontent.com/assets/4433943/26436253/2afd53f4-40e3-11e7-9791-b671042755d4.gif]]\n\n** Installation\n\nTo install, load yankee.el and require ~yankee~ (the following assumes the\nproject's parent directory has been added to the ~load-path~):\n\n#+BEGIN_SRC emacs-lisp\n;; ~/spacemacs.d/init.el\n(require 'yankee)\n#+END_SRC\n\n*** Suggested keybindings for evil-mode\n\nSpacemacs and Evil-mode users may find the following key bindings intuitive:\n\n#+BEGIN_SRC emacs-lisp\n;; ~/spacemacs.d/init.el\n(define-key evil-visual-state-map (kbd \"g y\") #'yankee/yank)\n#+END_SRC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmromer%2Fyankee.el","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmromer%2Fyankee.el","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmromer%2Fyankee.el/lists"}