forked from colonelpanic/dotfiles
sync-function-names with imalison:js-sync-function-names
This commit is contained in:
parent
59f5c472cc
commit
9c274c29f5
35
dotfiles/emacs.d/load.d/sync-function-names.el
Normal file
35
dotfiles/emacs.d/load.d/sync-function-names.el
Normal file
@ -0,0 +1,35 @@
|
||||
(defun imalison:get-args-location-or-eol ()
|
||||
(save-excursion
|
||||
(end-of-line)
|
||||
(let ((bound (point)))
|
||||
(beginning-of-line)
|
||||
(or (let ((value (re-search-forward "\(" bound t)))
|
||||
(when value (- value 1))) (progn (end-of-line) (point))))))
|
||||
|
||||
(defun imalison:js-get-params-string ()
|
||||
(save-excursion
|
||||
(end-of-line)
|
||||
(let ((bound (point)))
|
||||
(beginning-of-line)
|
||||
(if (re-search-forward "\(" bound t)
|
||||
(let ((start (progn (backward-char) (point)))
|
||||
(end (progn (forward-sexp) (point))))
|
||||
(buffer-substring (+ start 1) (- end 1)))
|
||||
""))))
|
||||
|
||||
(defun imalison:js-get-left-name ()
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(re-search-forward "\.?\\(\[^ .:\]*\\)\[ =:\n\]")
|
||||
(match-string-no-properties 1)))
|
||||
|
||||
(defun imalison:js-sync-function-names ()
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(let ((params-start (imalison:get-args-location-or-eol))
|
||||
(end (progn (end-of-line) (point))))
|
||||
(beginning-of-line)
|
||||
(or (re-search-forward "\[ =:\]+" end t)
|
||||
(end-of-line))
|
||||
(delete-region (point) params-start)
|
||||
(insert (format "function %s" (imalison:js-get-left-name))))))
|
Loading…
Reference in New Issue
Block a user