From 81c8016d1e296ed91af69f2d5bf435d7d657af04 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 12 Apr 2014 13:15:53 +0100 Subject: Restructure everything to use rcm https://github.com/thoughtbot/rcm --- tag-emacs/emacs.d/elisp/ap-functions.el | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tag-emacs/emacs.d/elisp/ap-functions.el (limited to 'tag-emacs/emacs.d/elisp/ap-functions.el') diff --git a/tag-emacs/emacs.d/elisp/ap-functions.el b/tag-emacs/emacs.d/elisp/ap-functions.el new file mode 100644 index 00000000..bdc7faef --- /dev/null +++ b/tag-emacs/emacs.d/elisp/ap-functions.el @@ -0,0 +1,47 @@ +;;;###autoload +(defun ap/remove-extra-cr () + "Remove extraneous CR codes from a file" + (interactive) + (save-excursion + (goto-char (point-min)) + (while (search-forward " +" nil t) + (replace-match "")))) + +;;;###autoload +(defun copy-rectangle (start end) + "Copy the region-rectangle." + (interactive "r") + (setq killed-rectangle (extract-rectangle start end))) + +;;;###autoload +(defun eval-and-replace () + "Replace the preceding sexp with its value." + (interactive) + (backward-kill-sexp) + (condition-case nil + (prin1 (eval (read (current-kill 0))) + (current-buffer)) + (error (message "Invalid expression") + (insert (current-kill 0))))) + +;;;###autoload +(defun shell-execute (to-current-buffer) + (interactive "P") + (let ((file-buffer (if (buffer-file-name) + (file-name-nondirectory (buffer-file-name)) + "")) + (command (read-shell-command "Shell command: " nil nil nil))) + (shell-command (replace-regexp-in-string "%" file-buffer command) to-current-buffer))) + +;;;###autoload +(defun narrow-to-region-indirect (start end) + "Restrict editing in this buffer to the current region, indirectly." + (interactive "r") + (deactivate-mark) + (let ((buf (clone-indirect-buffer nil nil))) + (with-current-buffer buf + (narrow-to-region start end)) + (switch-to-buffer buf))) + +(provide 'ap-functions) -- cgit 1.4.1