From e7657d6ba54ad5714657cff9be86ec416d342a4c Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 28 Apr 2013 20:54:18 +0100 Subject: Migrate repository from mercurial without history --- emacs/elisp/ap-functions.el | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 emacs/elisp/ap-functions.el (limited to 'emacs/elisp/ap-functions.el') diff --git a/emacs/elisp/ap-functions.el b/emacs/elisp/ap-functions.el new file mode 100644 index 00000000..d9278fa0 --- /dev/null +++ b/emacs/elisp/ap-functions.el @@ -0,0 +1,44 @@ +;;;###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 ap/byte-compile-get-dest (filename) + (let ((basename (file-name-nondirectory filename)) + (dirname (file-name-directory filename))) + (cond + ((string-equal basename "init.el") + (if (file-exists-p (concat user-emacs-directory "init.el")) + (concat user-emacs-directory "init.elc"))) + (t (let (byte-compile-dest-file-function) + (byte-compile-dest-file filename)))))) + +;;;###autoload +(defun shell-execute () + (interactive) + (let ((file-buffer (or (file-name-nondirectory (buffer-file-name)) "")) + (command (read-shell-command "Shell command: " nil nil nil))) + (shell-command (replace-regexp-in-string "%" file-buffer command)))) -- cgit 1.4.1