{"id":18862682,"url":"https://github.com/zk-phi/electric-case","last_synced_at":"2025-04-14T13:06:23.300Z","repository":{"id":6887936,"uuid":"8137437","full_name":"zk-phi/electric-case","owner":"zk-phi","description":"Insert camelCase, snake_case words without \"Shift\"ing","archived":false,"fork":false,"pushed_at":"2015-05-15T08:22:40.000Z","size":577,"stargazers_count":26,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T02:11:11.240Z","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.org","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}},"created_at":"2013-02-11T12:07:38.000Z","updated_at":"2023-07-28T08:06:31.000Z","dependencies_parsed_at":"2022-08-26T10:11:09.813Z","dependency_job_id":null,"html_url":"https://github.com/zk-phi/electric-case","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/zk-phi%2Felectric-case","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk-phi%2Felectric-case/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk-phi%2Felectric-case/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zk-phi%2Felectric-case/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zk-phi","download_url":"https://codeload.github.com/zk-phi/electric-case/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248886312,"owners_count":21177643,"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:28.722Z","updated_at":"2025-04-14T13:06:23.279Z","avatar_url":"https://github.com/zk-phi.png","language":"Emacs Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"* electric-case.el\n\ncamelCase、snake_case の識別子を Shift キーなしで入力\n\ninsert camelCase and snake_case words, without \"Shift\"ing\n\n** Screencast\n\n[[screencast.gif]]\n\n** Installation\n\nLoad this script\n\n: (require 'electric-case)\n\nand initialize in major-mode hooks.\n\n: (add-hook 'java-mode-hook 'electric-case-java-init)\n\nAnd when you type the following in java-mode for example,\n\n: public class test-class{\n:     public void test-method(void){\n\n=electric-case= automatically converts it into :\n\n: public class TestClass{\n:     public void testMethod(void){\n\nPreconfigured settings for some other languages are also\nprovided. Try:\n\n: (add-hook 'c-mode-hook electric-case-c-init)\n: (add-hook 'ahk-mode-hook electric-case-ahk-init)\n: (add-hook 'scala-mode-hook electric-case-scala-init)\n\nTo add support for other languages, please read section 2.\n\n** Customization\n*** =electric-case-convert-calls=\n\n=electric-case= do not convert other expressions than declarations by\ndefault. To enable conversion for other expressions, set\n=electric-case-convert-calls= non-nil.\n\n: (setq electric-case-convert-calls t)\n\nThis sometimes produces confusing results for novice users. For\nexample,\n\n: foo-bar\n\ndoes not mean \"foo minus bar\", but is converted to\n\n: fooBar\n\nTo make \"-\" counted as a subtraction or negation, insert whitespace\naround it.\n\n: foo - bar\n\nI recommend to keep =electric-case-convert-calls= =nil=, because it is\na kind of overkill. Once you declared a symbol, the symbol can be\ninserted easily using completion. This script is useful when you TYPE\nBY HAND camel-case or snake-case symbols. But in case you do not need\nto type, not to type seems much better.\n\n*** =electric-case-convert-nums/beginning/end=\n\nEven if =electric-case-convert-calls= is non-nil, numbers and hyphens\nat beginning/end of symbols are not converted.\n\n: -foo-1  =\u003e  -foo-1\n\nYou may change this behavior by setting some of three variables to\nnon-nil.\n\n: (setq electric-case-convert-nums t)      hyphens around numbers\n: (setq electric-case-convert-beginning t) hyphens at beginning of symbols\n: (setq electric-case-convert-end t)       hyphens at end of symbols\n\nWhen you insert an expression \"-foo--1--bar-\",\n\n:                 +---num\n:                 |     +--- num\n:                 V     V\n:  -  f  o  o  -  -  1  -  -  b  a  r  -\n:  ^           ^           ^           ^\n:  |           +--- end    |           +--- end\n:  +--- beginning          +--- beginning\n\nelectric-case will convert as follows:\n\n| num | beg | end | result       |\n|-----+-----+-----+--------------|\n| nil | nil | nil | -foo--1--bar-|\n| nil | nil | t   | -foo-1--bar  |\n| nil | t   | nil | Foo--1-Bar-  |\n| t   | nil | nil | -foo1Bar-    |\n| t   | t   | t   | Foo1Bar      |\n\n*** Overlays\n\nSymbols that may be converted by =electric-case= are shadowed by\ndefault. If this is not comfortable for you, evaluate following\nexpression to disable it.\n\n: (setq electric-case-pending-overlay nil)\n\nOr you may also choose another face to highlight pending symbols, that\nlooks better in your color-scheme.\n\n: (setq electric-case-pending-overlay 'highlight)\n\n** Implementing Language Supports\n\nThere are two important buffer-local variables:\n\n- =electric-case-criteria=\n\n  A function that defines which case to convert the symbol into. The\n  function will be given 2 arguments: the beginning and the end point\n  of the symbol. The function must return one of =camel=, =ucamel=,\n  =snake=, =usnake=, or =nil=. When the return value is =nil=, the\n  symbol is not converted.\n\n  Remember, that if =electric-case-convert-calls= is =nil=, symbols\n  not in declarations are not expected to be\n  converted. =electric-case= does not know whether the symbol is in a\n  declaration or not, so criteria functions must be aware of it.\n\n  Here is an example:\n\n  : (setq electric-case-criteria\n  :       (lambda (b e n)\n  :         (let ((proper (text-properties-at b)))\n  :           (cond ((member 'font-lock-function-name-face proper) 'snake)\n  :                 ((member 'font-lock-variable-name-face proper)\n  :                  (if (member '(cpp-macro) (c-guess-basic-syntax))\n  :                      'usnake 'snake))\n  :                 (electric-case-convert-calls 'snake)\n  :                 (t nil)))))\n\n  With the criteria function above, function-declarations and\n  variable-declarations are converted into snake_case. Macro\n  declarations are converted into UP_SNAKE_CASE. Other symbols are\n  converted into snake_case, if and only if\n  =electric-case-convert-calls= is non-nil. This may be one of the\n  minimal criteria functions for C-like language.\n\n- =electric-case-max-iteration=\n\n  For example, in Java, the syntactic category of the symbol\n  \"what-is-this\" below is not decidable.\n\n  : what-is-this\n\n  But when \" symbol;\" is added, now \"what-is-this\" is a class name.\n\n  : what-is-this symbol;\n\n  So electric-case can convert it.\n\n  : WhatIsThis symbol;\n\n  In this example, the symbol \"what-is-this\" must be checked\n  twice. So, =electric-case-max-iteration= for Java must be 2 or\n  greater. Otherwise, \"what-is-this\" is not checked twice, and is not\n  converted.\n\n** Known Bugs:\n\n- class name that ends with \"Class\" is treated as keyword \"class\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzk-phi%2Felectric-case","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzk-phi%2Felectric-case","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzk-phi%2Felectric-case/lists"}