Skip to content

Proposed simplification #29

Description

@Ergus

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.

Activity

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions