{"id":24310826,"url":"https://github.com/mschuldt/code-archive","last_synced_at":"2026-03-09T12:03:20.770Z","repository":{"id":74093316,"uuid":"137567079","full_name":"mschuldt/code-archive","owner":"mschuldt","description":"git supported code archive and reference for org-mode","archived":false,"fork":false,"pushed_at":"2021-07-11T22:03:56.000Z","size":36,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-02T12:13:07.659Z","etag":null,"topics":[],"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/mschuldt.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-16T08:52:39.000Z","updated_at":"2025-01-04T22:21:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c66c4ca-2112-48ac-806e-5d817b30e6f0","html_url":"https://github.com/mschuldt/code-archive","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/mschuldt%2Fcode-archive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mschuldt%2Fcode-archive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mschuldt%2Fcode-archive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mschuldt%2Fcode-archive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mschuldt","download_url":"https://codeload.github.com/mschuldt/code-archive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242532381,"owners_count":20144727,"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":[],"created_at":"2025-01-17T06:28:41.281Z","updated_at":"2026-03-09T12:03:20.725Z","avatar_url":"https://github.com/mschuldt.png","language":"Emacs Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nArchive and reference source code snippets\n\nThis package provides commands for saving selecting code regions and inserting them as org-mode styled code blocks.\nThese code blocks are tagged with an id that allows jumping back to the original source file.\nThe original source file is archived in a git managed repo each time a code block is saved.\n\nSaving full file copies enables referencing the orignal context and avoids the problem of locating bookmarked regions\nwhen the file becomes massively mutated or deleted. Using git solves\nthe problem of saving multiple versions of a file history in a space efficient way.\n\nAdditional helpers are provided for org-capture templates.\n\n* Installation and Setup\n=code-archive= is available from the MELPA package archive.\nSee https://melpa.org/#/getting-started for help getting it setup.\n\nin your config file:\n\nSet the code archive directory, which defaults to =~/code-archive=\n#+BEGIN_SRC emacs-lisp\n  (setq code-archive-dir \"~/code-archive-directory\")\n#+END_SRC\nThe variable =code-archive-src-map= maps major modes to the mode that is used for the org block source type. For example:\n#+BEGIN_SRC emacs-lisp\n  (push '(lisp-interaction-mode . \"emacs-lisp\") code-archive-src-map)\n#+END_SRC\nSet code-archive-src-map to nil to disable it.\n\nThese variables can also be edited using custom by selecting the group \"code-archive\"\n\n* Usage\n** Save and insert org code block\n 1. Select code. With a region selected in a source file run =M-x code-archive-save-code=,\n    This will save that region to an internal stack. Multiple regions can be saved consecutively in this way.\n    The source file will be added or updated in the git archive.\n\n 2. Insert the code block. =M-x code-archive-insert-org-block= will insert the most recently saved codeblock.\n    This should be called for each corresponding call to =code-archive-save-code=,\n** Jumping to source files\nWith the point at the start of a codeblock run =M-x code-archive-goto-src= to jump to the source file.\n\nThis will open the original source file if it has not changed. If it has been changed or deleted since the file\nwas archived, the archived version will be opened instead.\n\nArchived files are opened with =code-archive-mode= which recognizes the following keys:\n| o | Open the original source file at the same position if it exists |\n| q | Kill the buffer.                                                |\n\n** org-capture templates\nThe functions ~code-archive-do-org-capture~ and ~code-archive-org-src-tag~ are provided\nfor use in org-capture templates. They allow the capture template to archive the\nfile and save the region as a codeblock in some designated file.\nBoth require the file name to be passed to it with the =%F= escape.\n\n~code-archive-do-org-capture~ will create a codeblock out of the selected region, saving the\nfile to the git archive in the usual way. This is equivalent to calling manually calling =code-archive-save-code= in the source buffer and calling =code-archive-insert-org-block= in the capture buffer.\n\n~code-archive-org-src-tag~ will insert an org tag of the source type.\n\nAn example org capture template using both these functions:\n#+BEGIN_SRC emacs-lisp\n  (setq org-capture-templates\n        (quote ((\"c\" \"Code\" entry (file \"~/path/to/code.org\")\n                 \"* %? %(code-archive-org-src-tag \\\"%F\\\")\n   :PROPERTIES:\n   :FILE:     %F\n   :END:\n   %(code-archive-do-org-capture \\\"%F\\\")\")\n                )))\n#+END_SRC\n* Todo\n- modify html export to make the code blocks clickable, have it open the original or archived source file.\n- possibly enable multiple code archives. Currently not possible\n  because the code block ID is global.\n- Use the derived-mode-parent property to find the mode to use\nas the source block type. This will eliminate the need for code-archive-src-map\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmschuldt%2Fcode-archive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmschuldt%2Fcode-archive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmschuldt%2Fcode-archive/lists"}