Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed simplification #29

Open
Ergus opened this issue Jun 7, 2020 · 1 comment
Open

Proposed simplification #29

Ergus opened this issue Jun 7, 2020 · 1 comment
Assignees

Comments

@Ergus
Copy link

Ergus commented Jun 7, 2020

Hi:
I have seen the code and I wanted to simplify it a little bit the user customization. If you find it is useful you are free to modify it and use in the package's code:

(defcustom tests '(string-inflection-word-p
	      string-inflection-underscore-p
	      string-inflection-upcase-p
	      string-inflection-pascal-case-p
	      string-inflection-camelcase-p
	      string-inflection-kebab-case-p
	      ))
(defcustom funcs [
	     string-inflection-upcase-function
	     string-inflection-upcase-function
	     string-inflection-pascal-case-function
	     string-inflection-camelcase-function
	     string-inflection-kebab-case-function
	     string-inflection-capital-underscore-function
	     string-inflection-underscore-function
	     ])

(defun string-inflection-all-cycle-function (var)
  (interactive)
  (let ((temp tests)
	(it 0))
    (while temp
      (if (funcall (car temp) var)
	  (progn
	    (funcall (aref funcs it) var)
	    (setq temp nil))
	(setq it (1+ it))
	(setq temp (cdr temp))
	(unless temp
	  (funcall (aref funcs it) var))))))

This code has 2 main advantages:

  1. It is simpler to add/modify the functions in the cycle or their order
  2. It is trivial to modify this code to implement a reverse order function.
@akicho8 akicho8 self-assigned this Jun 7, 2020
@akicho8
Copy link
Owner

akicho8 commented Jun 7, 2020

I will tell the improvements, Thank you. 😃

Certainly simple.
However, because the people of the succession of the current state of cond condition code is easy to read, I thought it may remain for now.

After, if you want to customize, it recommends assemble yourself to take advantage of the primitive function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants