{"id":18862689,"url":"https://github.com/zk-phi/company-same-mode-buffers","last_synced_at":"2025-07-09T11:03:22.958Z","repository":{"id":152679598,"uuid":"317479613","full_name":"zk-phi/company-same-mode-buffers","owner":"zk-phi","description":"Company backend like `ac-source-words-in-same-mode-buffers'","archived":false,"fork":false,"pushed_at":"2024-09-24T04:21:44.000Z","size":278,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-21T13:42:20.829Z","etag":null,"topics":["emacs"],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zk-phi.png","metadata":{"files":{"readme":"Readme.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2020-12-01T08:48:57.000Z","updated_at":"2024-09-24T04:21:48.000Z","dependencies_parsed_at":"2024-11-08T04:36:07.210Z","dependency_job_id":"c5bec38d-d1c0-4db1-81f5-2204252d4816","html_url":"https://github.com/zk-phi/company-same-mode-buffers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zk-phi/company-same-mode-buffers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk-phi%2Fcompany-same-mode-buffers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk-phi%2Fcompany-same-mode-buffers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk-phi%2Fcompany-same-mode-buffers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk-phi%2Fcompany-same-mode-buffers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zk-phi","download_url":"https://codeload.github.com/zk-phi/company-same-mode-buffers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk-phi%2Fcompany-same-mode-buffers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264446718,"owners_count":23609632,"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"],"created_at":"2024-11-08T04:35:30.097Z","updated_at":"2025-07-09T11:03:22.895Z","avatar_url":"https://github.com/zk-phi.png","language":"Emacs Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"# company-same-mode-buffers.el / complete-same-mode-buffers.el\n\n![screencast](img/screencast.gif)\n\nCompany / completion-at-point backend to complete symbols in same mode buffers (like\n`ac-source-words-in-same-mode-buffers`)\n\nwith following features:\n\n- Reasonable performance powered by radix-tree\n- Optional flex matching\n- Optionally save candidates for future sessions\n\n## Installation\n\nload and initialize this package, and,\n\n### company\n\nadd to `company-backends`.\n\n```emacs-lisp\n(require 'company-same-mode-buffers)\n(company-same-mode-buffers-initialize)\n(push 'company-same-mode-buffers company-backends)\n```\n\n### completion-at-point (corfu)\n\nadd to `completion-at-point-functions`.\n\n```emacs-lisp\n(require complete-same-mode-buffers)\n(company-same-mode-buffers-initialize)\n(push 'complete-same-mode-buffers (default-value 'completion-at-point-functions))\n```\n\n## Customization\n### Matching algorithms\n\nYou may disable some of these matching algorithms, if you don't need\nthem.\n\n```emacs-lisp\n(setq company-same-mode-buffers-matchers\n      '(company-same-mode-buffers-matcher-basic\n        company-same-mode-buffers-matcher-partial\n        company-same-mode-buffers-matcher-exact-first-letter-flex-rest\n        ;; company-same-mode-buffers-matcher-flex\n        ))\n```\n\n- `company-same-mode-buffers-matcher-basic`\n\n  `compan` -\u003e `compan*` -\u003e `company-backends`\n\n- `company-same-mode-buffers-matcher-partial`\n\n  `co-ba` -\u003e `co*-ba*` -\u003e `company-backends`\n\n- `company-same-mode-buffers-matcher-exact-first-letter-flex-rest`\n\n  `cbns` -\u003e `c*n*b*s*` -\u003e `company-backends`\n\n- `company-same-mode-buffers-matcher-flex`\n\n  `pbns` -\u003e `*p*n*b*s*` -\u003e `company-backends`\n\n### History file\n\nYou may optionally save completion candidates to a file for future sessions.\n\n```emacs-lisp\n;; this line MUST be put before \"company-same-mode-buffers-initialize\"\n(setq company-same-mode-buffers-history-file \"~/.emacs.d/.company-same-mode-buffers-history\")\n(company-same-mode-buffers-initialize)\n```\n\n## Internals\n### Symbol caching\n\nIn order to speed-up searching, symbols are collected in per-buffer radix-trees, called \"cache\"s.\n\nTo avoid heavy updating, the current buffer's cache is NOT updated. Instead, symbols in the current buffer are searched by simple regex-search.\n\n### History file internals (v2)\n\nAn alist of the form `alist[timestamp =\u003e alist[major-mode =\u003e list[symbol]]]` is saved to the history\nfile.\n\n``` emacs-lisp\n;; example:\n((\u003ctimestamp\u003e\n  (emacs-lisp-mode \"save-excursion\" \"defun\" \"defvar\")\n  (js-mode \"function\" \"return\"))\n (\u003ctimestamp\u003e\n  (emacs-lisp-mode \"defconst\" \"defun\") ; duplicated symbols may saved with different timestamps\n  (css-mode \"margin\")))\n```\n\n### Saving candidates\n\nWhen killing Emacs, `company-same-mode-buffers` visits all `prog-mode` buffers and collects all\nsymbols in these buffers. Then for each symbols collected, if the symbol\n\n1. appears in more than two buffers, and\n2. appears in at least one user-modified buffers,\n\nthe symbol is added to the new history entry.\n\nTo save memory, symbols that appear in only one buffer (like buffer-local variables), and symbols that do not appear in buffers that user modify (like logs, or files created with code-generators), are not saved.\n\nA known downside is: If a buffer is killed before killing Emacs, symbols in that buffer are NOT\nsaved.\n\n### Loading history file\n\nAll symbols in unexpired history entries are simply inserted into a temporary buffer, with\ncorresponding major-mode. One temporary buffer is created for one major-mode.\n\n``` emacs-lisp\n;; a temporary buffer with emacs-lisp-mode\nsave-excursion defun defvar defconst defun\n```\n\n``` javascript\n// a temporary buffer with js-mode\nfunction return\n```\n\n``` css\n/* a temporary buffer with css-mode */\nmargin\n```\n\nThese temporary buffers are also visited when saving the history file. As a result,\n\nnew symbols are added to the history file, when\n\n1. the symbol appears in more than two buffers, and\n2. the symbol appears in at least one user-modified buffers\n\nand symbols from the previous sessions are re-added (with updated timestamp) when\n\n1. the symbol appears in at least one user-modified, non-temporary buffers\n\nOther symbols from the previous sessions are kept as they are (without updated timestamp).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzk-phi%2Fcompany-same-mode-buffers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzk-phi%2Fcompany-same-mode-buffers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzk-phi%2Fcompany-same-mode-buffers/lists"}