Commits

March Liu committed d5d67e5

reflector the warp it mode

Comments (0)

Files changed (3)

raw-elisp/march/macos/.emacs

 
 (add-to-list 'load-path "~/site-lisp")
 
-;; warp settings
-(require 'warp-it)
-(global-set-key (kbd "C-'") 'warp-word-quote)
-(global-set-key (kbd "C-'") 'warp-word)
+;; wrap settings
+(require 'wrap-it)
+(global-set-key (kbd "C-'") 'wrap-word-quote)
+(global-set-key (kbd "C-'") 'wrap-word)
 
 (load-file "~/site-lisp/highlight-regexp.el")
 

raw-elisp/march/macos/site-lisp/warp-it.el

-(defun warp-it (beg end left right)
-  "warp beg to end use left and right"
-  (let ((p (point)))
-    (goto-char end)
-    (insert right)
-    (goto-char beg)
-    (insert left)
-    (goto-char p))  
-)
-
-(defun warp-thing-helper (thing left right)
-  "warp these"
-  (let ((contents (thing-at-point-with-bounds thing)))
-       (let ((beg (car (cdr contents)))
-             (end (cdr (cdr contents))))
-         (warp-it beg end left right))))
-
-(defun warp-thing (thing symbols)
-  "warp the thing at point"
-  (interactive "Sthing:\nssymbols:\n")
-  (warp-thing-helper thing 
-              (substring symbols 0 1)
-              (substring symbols 1 2))
-)
-
-(defun warp-region (symbols)
-  "warp the region"
-  (interactive "ssymbols:\n")
-  (warp-it (region-beginning)
-                       (region-end)
-                       (substring symbols 0 1)
-                       (substring symbols 1 2)))
-
-;; it cannot work right at now
-(defmacro warp-thing-macro (thing)
-  '(lambda (symbols)
-     (interactive "ssymbols:\n")
-     (warp-thing-helper 'thing 
-                        (substring symbols 0 1)
-                        (substring symbols 1 2))))
-
-(defun warp-word (symbols)
-  "warp the word at point"
-  (interactive "ssymbols:\n")
-  (warp-thing-helper 'word 
-              (substring symbols 0 1)
-              (substring symbols 1 2))
-)
-
-(defun warp-word-quote ()
-  "warp the word at point"
-  (interactive)
-  (warp-thing-helper 'word "\"" "\""))
-
-(defun warp-line (symbols)
-  "warp the line at point"
-  (interactive "ssymbols:\n")
-  (warp-thing-helper 'line 
-              (substring symbols 0 1)
-              (substring symbols 1 2))
-)
-
-(defun warp-line-quote ()
-  "warp the line at point"
-  (interactive)
-  (warp-thing-helper 'line "\"" "\""))
-
-(defun warp-url (symbols)
-  "warp the url at point"
-  (interactive "ssymbols:\n")
-  (warp-thing-helper 'url 
-              (substring symbols 0 1)
-              (substring symbols 1 2))
-)
-
-(defun warp-url-quote ()
-  "warp the url at point"
-  (interactive)
-  (warp-thing-helper 'url "\"" "\""))
-
-
-(provide 'warp-it)

raw-elisp/march/macos/site-lisp/wrap-it.el

+(defun wrap-it (beg end left right)
+  "wrap beg to end use left and right"
+  (save-excursion ((goto-char end)
+                   (insert right)
+                   (goto-char beg)
+                   (insert left))))
+
+(defun wrap-thing-helper (thing left right)
+  "wrap these"
+  (let ((contents (thing-at-point-with-bounds thing)))
+       (let ((beg (car (cdr contents)))
+             (end (cdr (cdr contents))))
+         (wrap-it beg end left right))))
+
+(defun wrap-thing (thing symbols)
+  "wrap the thing at point"
+  (interactive "Sthing:\nssymbols:\n")
+  (wrap-thing-helper thing 
+              (substring symbols 0 1)
+              (substring symbols 1 2))
+)
+
+(defun wrap-region (symbols)
+  "wrap the region"
+  (interactive "ssymbols:\n")
+  (wrap-it (region-beginning)
+                       (region-end)
+                       (substring symbols 0 1)
+                       (substring symbols 1 2)))
+
+;; it cannot work right at now
+(defmacro wrap-thing-macro (thing)
+  '(lambda (symbols)
+     (interactive "ssymbols:\n")
+     (wrap-thing-helper 'thing 
+                        (substring symbols 0 1)
+                        (substring symbols 1 2))))
+
+(defun wrap-word (symbols)
+  "wrap the word at point"
+  (interactive "ssymbols:\n")
+  (wrap-thing-helper 'word 
+              (substring symbols 0 1)
+              (substring symbols 1 2))
+)
+
+(defun wrap-word-quote ()
+  "wrap the word at point"
+  (interactive)
+  (wrap-thing-helper 'word "\"" "\""))
+
+(defun wrap-line (symbols)
+  "wrap the line at point"
+  (interactive "ssymbols:\n")
+  (wrap-thing-helper 'line 
+              (substring symbols 0 1)
+              (substring symbols 1 2))
+)
+
+(defun wrap-line-quote ()
+  "wrap the line at point"
+  (interactive)
+  (wrap-thing-helper 'line "\"" "\""))
+
+(defun wrap-url (symbols)
+  "wrap the url at point"
+  (interactive "ssymbols:\n")
+  (wrap-thing-helper 'url 
+              (substring symbols 0 1)
+              (substring symbols 1 2))
+)
+
+(defun wrap-url-quote ()
+  "wrap the url at point"
+  (interactive)
+  (wrap-thing-helper 'url "\"" "\""))
+
+
+(provide 'wrap-it)