From 75986839e1c1a8197becd5dd2532aa36d0e32d76 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Thu, 11 May 2023 18:18:10 +0200 Subject: [PATCH] update string-inflection Signed-off-by: Andreas Gerler --- .../string-inflection-pkg.el | 2 - .../string-inflection-autoloads.el | 7 ++- .../string-inflection-pkg.el | 2 + .../string-inflection.el | 42 +++++++++++--- elpa/string-inflection-readme.txt | 58 +++++++++++++++++++ 5 files changed, 99 insertions(+), 12 deletions(-) delete mode 100644 elpa/string-inflection-20210918.419/string-inflection-pkg.el rename elpa/{string-inflection-20210918.419 => string-inflection-20220910.1306}/string-inflection-autoloads.el (88%) create mode 100644 elpa/string-inflection-20220910.1306/string-inflection-pkg.el rename elpa/{string-inflection-20210918.419 => string-inflection-20220910.1306}/string-inflection.el (91%) create mode 100644 elpa/string-inflection-readme.txt diff --git a/elpa/string-inflection-20210918.419/string-inflection-pkg.el b/elpa/string-inflection-20210918.419/string-inflection-pkg.el deleted file mode 100644 index 9d7ff22c..00000000 --- a/elpa/string-inflection-20210918.419/string-inflection-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; Generated package description from /Users/baron/.emacs.d/elpa/string-inflection-20210918.419/string-inflection.el -*- no-byte-compile: t -*- -(define-package "string-inflection" "20210918.419" "underscore -> UPCASE -> CamelCase -> lowerCamelCase conversion of names" 'nil :commit "fd7926ac17293e9124b31f706a4e8f38f6a9b855" :authors '(("akicho8" . "akicho8@gmail.com")) :maintainer '("akicho8" . "akicho8@gmail.com") :keywords '("elisp")) diff --git a/elpa/string-inflection-20210918.419/string-inflection-autoloads.el b/elpa/string-inflection-20220910.1306/string-inflection-autoloads.el similarity index 88% rename from elpa/string-inflection-20210918.419/string-inflection-autoloads.el rename to elpa/string-inflection-20220910.1306/string-inflection-autoloads.el index b44d44c5..d17357a9 100644 --- a/elpa/string-inflection-20210918.419/string-inflection-autoloads.el +++ b/elpa/string-inflection-20220910.1306/string-inflection-autoloads.el @@ -1,4 +1,4 @@ -;;; string-inflection-autoloads.el --- automatically extracted autoloads +;;; string-inflection-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- ;; ;;; Code: @@ -13,6 +13,9 @@ (autoload 'string-inflection-ruby-style-cycle "string-inflection" "\ foo_bar => FOO_BAR => FooBar => foo_bar" t nil) +(autoload 'string-inflection-elixir-style-cycle "string-inflection" "\ +foo_bar => FooBar => foo_bar" t nil) + (autoload 'string-inflection-python-style-cycle "string-inflection" "\ foo_bar => FOO_BAR => FooBar => foo_bar" t nil) @@ -43,7 +46,7 @@ FOO_BAR format" t nil) (autoload 'string-inflection-kebab-case "string-inflection" "\ foo-bar format" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "string-inflection" '("string-inflection-"))) +(register-definition-prefixes "string-inflection" '("string-inflection-")) ;;;*** diff --git a/elpa/string-inflection-20220910.1306/string-inflection-pkg.el b/elpa/string-inflection-20220910.1306/string-inflection-pkg.el new file mode 100644 index 00000000..bc44cdaf --- /dev/null +++ b/elpa/string-inflection-20220910.1306/string-inflection-pkg.el @@ -0,0 +1,2 @@ +;;; Generated package description from string-inflection.el -*- no-byte-compile: t -*- +(define-package "string-inflection" "20220910.1306" "underscore -> UPCASE -> CamelCase -> lowerCamelCase conversion of names" 'nil :commit "50ad54970b3cc79b6b83979bde9889ad9a9e1a9c" :authors '(("akicho8" . "akicho8@gmail.com")) :maintainers '(("akicho8" . "akicho8@gmail.com")) :maintainer '("akicho8" . "akicho8@gmail.com") :keywords '("elisp")) diff --git a/elpa/string-inflection-20210918.419/string-inflection.el b/elpa/string-inflection-20220910.1306/string-inflection.el similarity index 91% rename from elpa/string-inflection-20210918.419/string-inflection.el rename to elpa/string-inflection-20220910.1306/string-inflection.el index f41cf6c1..90c9dd26 100644 --- a/elpa/string-inflection-20210918.419/string-inflection.el +++ b/elpa/string-inflection-20220910.1306/string-inflection.el @@ -4,8 +4,8 @@ ;; Author: akicho8 ;; Keywords: elisp -;; Package-Version: 20210918.419 -;; Package-Commit: fd7926ac17293e9124b31f706a4e8f38f6a9b855 +;; Package-Version: 20220910.1306 +;; Package-Commit: 50ad54970b3cc79b6b83979bde9889ad9a9e1a9c ;; Version: 1.0.16 ;; This file is free software; you can redistribute it and/or modify @@ -28,9 +28,10 @@ ;; There are three main functions: ;; ;; 1. For Ruby -> string-inflection-ruby-style-cycle (foo_bar => FOO_BAR => FooBar => foo_bar) -;; 2. For Python -> string-inflection-python-style-cycle (foo_bar => FOO_BAR => FooBar => foo_bar) -;; 3. For Java -> string-inflection-java-style-cycle (fooBar => FOO_BAR => FooBar => fooBar) -;; 4. For All -> string-inflection-all-cycle (foo_bar => FOO_BAR => FooBar => fooBar => foo-bar => Foo_Bar => foo_bar) +;; 2. For Elixir -> string-inflection-elixir-style-cycle (foo_bar => FooBar => foo_bar) +;; 3. For Python -> string-inflection-python-style-cycle (foo_bar => FOO_BAR => FooBar => foo_bar) +;; 4. For Java -> string-inflection-java-style-cycle (fooBar => FOO_BAR => FooBar => fooBar) +;; 5. For All -> string-inflection-all-cycle (foo_bar => FOO_BAR => FooBar => fooBar => foo-bar => Foo_Bar => foo_bar) ;; ;; ;; Example 1: @@ -53,6 +54,9 @@ ;; ;; for python ;; ((eq major-mode 'python-mode) ;; (string-inflection-python-style-cycle)) +;; ;; for elixir +;; ((eq major-mode 'elixir-mode) +;; (string-inflection-elixir-style-cycle)) ;; (t ;; ;; default ;; (string-inflection-ruby-style-cycle)))) @@ -70,6 +74,11 @@ ;; '(lambda () ;; (local-set-key (kbd "C-c C-u") 'string-inflection-ruby-style-cycle))) ;; +;; ;; for elixir +;; (add-hook 'elixir-mode-hook +;; '(lambda () +;; (local-set-key (kbd "C-c C-u") 'string-inflection-elixir-style-cycle))) +;; ;; ;; for python ;; (add-hook 'python-mode-hook ;; '(lambda () @@ -100,11 +109,13 @@ the beginning." (defconst string-inflection-word-chars "a-zA-Z0-9_-") (defcustom string-inflection-erase-chars-when-region "./" - "When selected in the region, this character is included in the transformation as part of the string. + "When selected in the region, this character is included in the transformation +as part of the string. Exactly assume that the underscore exists. -For example, when you select `Foo/Bar', it is considered that `Foo_Bar' is selected. -If include `:', select `FOO::VERSION' to run `M-x\ string-inflection-underscore' to `foo_version'." +For example, when you select `Foo/Bar', it is considered that `Foo_Bar' is +selected. If include `:', select `FOO::VERSION' to run +`M-x\ string-inflection-underscore' to `foo_version'." :group 'string-inflection :type 'string) @@ -119,6 +130,13 @@ If include `:', select `FOO::VERSION' to run `M-x\ string-inflection-underscore' (fset 'string-inflection-cycle 'string-inflection-ruby-style-cycle) +;;;###autoload +(defun string-inflection-elixir-style-cycle () + "foo_bar => FooBar => foo_bar" + (interactive) + (string-inflection-insert + (string-inflection-elixir-style-cycle-function (string-inflection-get-current-word)))) + ;;;###autoload (defun string-inflection-python-style-cycle () "foo_bar => FOO_BAR => FooBar => foo_bar" @@ -322,6 +340,14 @@ If include `:', select `FOO::VERSION' to run `M-x\ string-inflection-underscore' (defalias 'string-inflection-python-style-cycle-function 'string-inflection-ruby-style-cycle-function) +(defun string-inflection-elixir-style-cycle-function (str) + "foo_bar => FooBar => foo_bar" + (cond + ((string-inflection-underscore-p str) + (string-inflection-pascal-case-function str)) + (t + (string-inflection-underscore-function str)))) + (defun string-inflection-java-style-cycle-function (str) "fooBar => FOO_BAR => FooBar => fooBar" (cond diff --git a/elpa/string-inflection-readme.txt b/elpa/string-inflection-readme.txt new file mode 100644 index 00000000..6daa1c92 --- /dev/null +++ b/elpa/string-inflection-readme.txt @@ -0,0 +1,58 @@ +Main functions are three + + 1. For Ruby -> string-inflection-ruby-style-cycle (foo_bar => FOO_BAR => FooBar => foo_bar) + 2. For Python -> string-inflection-python-style-cycle (foo_bar => FOO_BAR => FooBar => foo_bar) + 3. For Java -> string-inflection-java-style-cycle (fooBar => FOO_BAR => FooBar => fooBar) + 4. For All -> string-inflection-all-cycle (foo_bar => FOO_BAR => FooBar => fooBar => foo-bar => Foo_Bar => foo_bar) + + +Setting Example 1 + + (require 'string-inflection) + (global-unset-key (kbd "C-q")) + ;; C-q C-u is the key bindings similar to Vz Editor. + (global-set-key (kbd "C-q C-u") 'my-string-inflection-cycle-auto) + + (defun my-string-inflection-cycle-auto () + "switching by major-mode" + (interactive) + (cond + ;; for emacs-lisp-mode + ((eq major-mode 'emacs-lisp-mode) + (string-inflection-all-cycle)) + ;; for java + ((eq major-mode 'java-mode) + (string-inflection-java-style-cycle)) + ;; for python + ((eq major-mode 'python-mode) + (string-inflection-python-style-cycle)) + (t + ;; default + (string-inflection-ruby-style-cycle)))) + + +Setting Example 2 + + (require 'string-inflection) + + ;; default + (global-set-key (kbd "C-c C-u") 'string-inflection-all-cycle) + + ;; for ruby + (add-hook 'ruby-mode-hook + '(lambda () + (local-set-key (kbd "C-c C-u") 'string-inflection-ruby-style-cycle))) + + ;; for python + (add-hook 'python-mode-hook + '(lambda () + (local-set-key (kbd "C-c C-u") 'string-inflection-python-style-cycle))) + + ;; for java + (add-hook 'java-mode-hook + '(lambda () + (local-set-key (kbd "C-c C-u") 'string-inflection-java-style-cycle))) + +You may also consider setting `string-inflection-skip-backward-when-done' to +`t' if you don't like `string-inflect' moving your point to the end of the +word -- 2.47.3