Clean up prelude-mode.
This commit is contained in:
parent
00661efa2a
commit
64aa0ee0c5
2 changed files with 23 additions and 29 deletions
|
@ -69,30 +69,19 @@
|
||||||
(buffer-substring (region-beginning) (region-end))
|
(buffer-substring (region-beginning) (region-end))
|
||||||
(read-string "Google: "))))))
|
(read-string "Google: "))))))
|
||||||
|
|
||||||
(defun prelude-indent-rigidly-and-copy-to-clipboard (begin end indent)
|
(defun prelude-indent-rigidly-and-copy-to-clipboard (begin end arg)
|
||||||
"Copy the selected code region to the clipboard, indented according
|
"Indent region between BEGIN and END by ARG columns and copy to clipboard."
|
||||||
to Markdown blockquote rules."
|
(interactive "r\nP")
|
||||||
(let ((buffer (current-buffer)))
|
(let ((arg (or arg 4))
|
||||||
|
(buffer (current-buffer)))
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert-buffer-substring-no-properties buffer begin end)
|
(insert-buffer-substring-no-properties buffer begin end)
|
||||||
(indent-rigidly (point-min) (point-max) indent)
|
(indent-rigidly (point-min) (point-max) arg)
|
||||||
(clipboard-kill-ring-save (point-min) (point-max)))))
|
(clipboard-kill-ring-save (point-min) (point-max)))))
|
||||||
|
|
||||||
(defun prelude-indent-blockquote-and-copy-to-clipboard (begin end)
|
|
||||||
"Copy the selected code region to the clipboard, indented according
|
|
||||||
to markdown blockquote rules (useful to copy snippets to StackOverflow, Assembla, Github."
|
|
||||||
(interactive "r")
|
|
||||||
(prelude-indent-rigidly-and-copy-to-clipboard begin end 4))
|
|
||||||
|
|
||||||
(defun prelude-indent-nested-blockquote-and-copy-to-clipboard (begin end)
|
|
||||||
"Copy the selected code region to the clipboard, indented according
|
|
||||||
to markdown blockquote rules. Useful to add snippets under bullet points."
|
|
||||||
(interactive "r")
|
|
||||||
(prelude-indent-rigidly-and-copy-to-clipboard begin end 6))
|
|
||||||
|
|
||||||
(defun prelude-insert-empty-line ()
|
(defun prelude-insert-empty-line ()
|
||||||
"Insert an empty line after the current line and positon
|
"Insert an empty line after the current line.
|
||||||
the curson at its beginning, according to the current mode."
|
Position the cursor at its beginning, according to the current mode."
|
||||||
(interactive)
|
(interactive)
|
||||||
(move-end-of-line nil)
|
(move-end-of-line nil)
|
||||||
(open-line 1)
|
(open-line 1)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
;; Boston, MA 02110-1301, USA.
|
;; Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
(require 'easymenu)
|
||||||
|
|
||||||
(defvar prelude-mode-map
|
(defvar prelude-mode-map
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
|
@ -50,11 +51,13 @@
|
||||||
(define-key map (kbd "C-c r") 'prelude-rename-file-and-buffer)
|
(define-key map (kbd "C-c r") 'prelude-rename-file-and-buffer)
|
||||||
(define-key map (kbd "C-c t") 'prelude-visit-term-buffer)
|
(define-key map (kbd "C-c t") 'prelude-visit-term-buffer)
|
||||||
(define-key map (kbd "C-c k") 'prelude-kill-other-buffers)
|
(define-key map (kbd "C-c k") 'prelude-kill-other-buffers)
|
||||||
|
(define-key map (kbd "C-c TAB") 'prelude-indent-rigidly-and-copy-to-clipboard)
|
||||||
(define-key map (kbd "C-c h") 'helm-prelude)
|
(define-key map (kbd "C-c h") 'helm-prelude)
|
||||||
map)
|
map)
|
||||||
"Keymap for Prelude mode.")
|
"Keymap for Prelude mode.")
|
||||||
|
|
||||||
(defun prelude-mode-add-menu ()
|
(defun prelude-mode-add-menu ()
|
||||||
|
"Add a menu entry for `prelude-mode' under Tools."
|
||||||
(easy-menu-add-item nil '("Tools")
|
(easy-menu-add-item nil '("Tools")
|
||||||
'("Prelude"
|
'("Prelude"
|
||||||
("Files"
|
("Files"
|
||||||
|
@ -74,8 +77,7 @@
|
||||||
["Indent buffer" prelude-indent-buffer]
|
["Indent buffer" prelude-indent-buffer]
|
||||||
["Indent buffer or region" prelude-indent-buffer-or-region]
|
["Indent buffer or region" prelude-indent-buffer-or-region]
|
||||||
["Duplicate line or region" prelude-duplicate-current-line-or-region]
|
["Duplicate line or region" prelude-duplicate-current-line-or-region]
|
||||||
["Copy to clipboard as blockquote" prelude-indent-blockquote-and-copy-to-clipboard]
|
["Indent rigidly and copy to clipboard" prelude-indent-rigidly-and-copy-to-clipboard]
|
||||||
["Copy to clipboard as nested blockqoute" prelude-indent-nested-blockquote-and-copy-to-clipboard]
|
|
||||||
["Insert date" prelude-insert-date]
|
["Insert date" prelude-insert-date]
|
||||||
["Eval and replace" prelude-eval-and-replace])
|
["Eval and replace" prelude-eval-and-replace])
|
||||||
|
|
||||||
|
@ -94,18 +96,11 @@
|
||||||
(easy-menu-add-item nil '("Tools") '("--") "Search Files (Grep)..."))
|
(easy-menu-add-item nil '("Tools") '("--") "Search Files (Grep)..."))
|
||||||
|
|
||||||
(defun prelude-mode-remove-menu ()
|
(defun prelude-mode-remove-menu ()
|
||||||
|
"Remove `prelude-mode' menu entry."
|
||||||
(easy-menu-remove-item nil '("Tools") "Prelude")
|
(easy-menu-remove-item nil '("Tools") "Prelude")
|
||||||
(easy-menu-remove-item nil '("Tools") "--"))
|
(easy-menu-remove-item nil '("Tools") "--"))
|
||||||
|
|
||||||
;; define minor mode
|
;; define minor mode
|
||||||
(define-globalized-minor-mode prelude-global-mode prelude-mode prelude-on)
|
|
||||||
|
|
||||||
(defun prelude-on ()
|
|
||||||
(prelude-mode +1))
|
|
||||||
|
|
||||||
(defun prelude-off ()
|
|
||||||
(prelude-mode -1))
|
|
||||||
|
|
||||||
(define-minor-mode prelude-mode
|
(define-minor-mode prelude-mode
|
||||||
"Minor mode to consolidate Emacs Prelude extensions.
|
"Minor mode to consolidate Emacs Prelude extensions.
|
||||||
|
|
||||||
|
@ -118,5 +113,15 @@
|
||||||
;; on stop
|
;; on stop
|
||||||
(prelude-mode-remove-menu)))
|
(prelude-mode-remove-menu)))
|
||||||
|
|
||||||
|
(define-globalized-minor-mode prelude-global-mode prelude-mode prelude-on)
|
||||||
|
|
||||||
|
(defun prelude-on ()
|
||||||
|
"Turn on `prelude-mode'."
|
||||||
|
(prelude-mode +1))
|
||||||
|
|
||||||
|
(defun prelude-off ()
|
||||||
|
"Turn off `prelude-mode'."
|
||||||
|
(prelude-mode -1))
|
||||||
|
|
||||||
(provide 'prelude-mode)
|
(provide 'prelude-mode)
|
||||||
;;; prelude-mode.el ends here
|
;;; prelude-mode.el ends here
|
||||||
|
|
Loading…
Reference in a new issue