Config file commit
This commit is contained in:
parent
f05ecc1625
commit
5da8ddda2a
10 changed files with 792 additions and 0 deletions
65
elisp/evil-ex-registers.el
Normal file
65
elisp/evil-ex-registers.el
Normal file
|
@ -0,0 +1,65 @@
|
|||
;;; evil-ex-registers.el --- Command to paste from register in ex mode
|
||||
|
||||
;; Author: INA Lintaro <tarao.gnn at gmail.com>
|
||||
;; URL: http://github.com/tarao/evil-plugins
|
||||
;; Version: 0.1
|
||||
;; Keywords: evil, plugin
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
;;; License:
|
||||
;;
|
||||
;; This program is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'evil)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(defalias 'evil-orig-get-register (symbol-function 'evil-get-register))
|
||||
|
||||
(defun evil-get-spec-register (register &optional noerror)
|
||||
"Return contents of REGISTER.
|
||||
Signal an error if empty, unless NOERROR is non-nil.
|
||||
|
||||
Support some registers listed below in addition to
|
||||
`evil-get-register'.
|
||||
the file name under the cursor
|
||||
the expanded file name under the cursor
|
||||
the word under the cursor
|
||||
the WORD under the cursor"
|
||||
(cond
|
||||
((or (= register ?\C-f) ; ^F the filename under the cursor
|
||||
(= register ?\C-p)) ; ^P the expanded filename under the cursor
|
||||
(let ((file (thing-at-point 'filename)))
|
||||
(or (and file (= register ?\C-p) (expand-file-name file)) file)))
|
||||
((or (= register ?\C-w) ; ^W the word under the cursor
|
||||
(= register ?\C-a)) ; ^A the WORD under the cursor
|
||||
(let* ((word (if (= register ?\C-a) #'evil-move-WORD #'evil-move-word))
|
||||
(range (evil-inner-object-range nil nil nil nil word)))
|
||||
(filter-buffer-substring (nth 0 range) (nth 1 range))))
|
||||
(t (evil-orig-get-register register noerror))))
|
||||
|
||||
(defun evil-ex-paste-from-register (&optional register)
|
||||
"Paste from REGISTER in command line."
|
||||
(interactive)
|
||||
(flet ((evil-get-register (register &optional noerror)
|
||||
(with-current-buffer evil-ex-current-buffer
|
||||
(evil-get-spec-register register noerror))))
|
||||
(if (called-interactively-p 'any)
|
||||
(call-interactively #'evil-paste-from-register)
|
||||
(evil-paste-from-register register))))
|
||||
|
||||
(provide 'evil-ex-registers)
|
||||
;;; evil-ex-registers.el ends here
|
89
elisp/rotate-text.el
Normal file
89
elisp/rotate-text.el
Normal file
|
@ -0,0 +1,89 @@
|
|||
;; From <http://www.emacswiki.org/emacs/RotateText>
|
||||
|
||||
(defvar rotate-text-rotations
|
||||
'(("true" "false")
|
||||
("yes" "no")
|
||||
("left" "right" "top" "bottom")
|
||||
("width" "height"))
|
||||
"List of text rotation sets.")
|
||||
|
||||
(defun rotate-region (beg end)
|
||||
"Rotate all matches in `rotate-text-rotations' between point and mark."
|
||||
(interactive "r")
|
||||
(let ((regexp (rotate-convert-rotations-to-regexp
|
||||
rotate-text-rotations))
|
||||
(end-mark (copy-marker end)))
|
||||
(save-excursion
|
||||
(goto-char beg)
|
||||
(while (re-search-forward regexp (marker-position end-mark) t)
|
||||
(let* ((found (match-string 0))
|
||||
(replace (rotate-next found)))
|
||||
(replace-match replace))))))
|
||||
|
||||
(defun rotate-string (string &optional rotations)
|
||||
"Rotate all matches in STRING using associations in ROTATIONS.
|
||||
If ROTATIONS are not given it defaults to `rotate-text-rotations'."
|
||||
(let ((regexp (rotate-convert-rotations-to-regexp
|
||||
(or rotations rotate-text-rotations)))
|
||||
(start 0))
|
||||
(while (string-match regexp string start)
|
||||
(let* ((found (match-string 0 string))
|
||||
(replace (rotate-next
|
||||
found
|
||||
(or rotations rotate-text-rotations))))
|
||||
(setq start (+ (match-end 0)
|
||||
(- (length replace) (length found))))
|
||||
(setq string (replace-match replace nil t string))))
|
||||
string))
|
||||
|
||||
(defun rotate-next (string &optional rotations)
|
||||
"Return the next element after STRING in ROTATIONS."
|
||||
(let ((rots (rotate-get-rotations-for
|
||||
string
|
||||
(or rotations rotate-text-rotations))))
|
||||
(if (> (length rots) 1)
|
||||
(error (format "Ambiguous rotation for %s" string))
|
||||
(if (< (length rots) 1)
|
||||
;; If we get this far, this should not occur:
|
||||
(error (format "Unknown rotation for %s" string))
|
||||
(let ((occurs-in-rots (member string (car rots))))
|
||||
(if (null occurs-in-rots)
|
||||
;; If we get this far, this should *never* occur:
|
||||
(error (format "Unknown rotation for %s" string))
|
||||
(if (null (cdr occurs-in-rots))
|
||||
(caar rots)
|
||||
(cadr occurs-in-rots))))))))
|
||||
|
||||
(defun rotate-get-rotations-for (string &optional rotations)
|
||||
"Return the string rotations for STRING in ROTATIONS."
|
||||
(remq nil (mapcar (lambda (rot) (if (member string rot) rot))
|
||||
(or rotations rotate-text-rotations))))
|
||||
|
||||
(defun rotate-convert-rotations-to-regexp (rotations)
|
||||
(regexp-opt (rotate-flatten-list rotations)))
|
||||
|
||||
(defun rotate-flatten-list (list-of-lists)
|
||||
"Flatten LIST-OF-LISTS to a single list.
|
||||
Example:
|
||||
(rotate-flatten-list '((a b c) (1 ((2 3)))))
|
||||
=> (a b c 1 2 3)"
|
||||
(if (null list-of-lists)
|
||||
list-of-lists
|
||||
(if (listp list-of-lists)
|
||||
(append (rotate-flatten-list (car list-of-lists))
|
||||
(rotate-flatten-list (cdr list-of-lists)))
|
||||
(list list-of-lists))))
|
||||
|
||||
(defun rotate-word-at-point ()
|
||||
"Rotate word at point based on sets in `rotate-text-rotations'."
|
||||
(interactive)
|
||||
(let ((bounds (bounds-of-thing-at-point 'word))
|
||||
(opoint (point)))
|
||||
(when (consp bounds)
|
||||
(let ((beg (car bounds))
|
||||
(end (copy-marker (cdr bounds))))
|
||||
(rotate-region beg end)
|
||||
(goto-char (if (> opoint end) end opoint))))))
|
||||
|
||||
|
||||
(provide 'rotate-text)
|
Loading…
Add table
Add a link
Reference in a new issue