A bit of cleanup and doc-string fixes

This commit is contained in:
Bozhidar Batsov 2013-03-07 09:57:33 +02:00
parent 5803d30af6
commit 00661efa2a
24 changed files with 39 additions and 61 deletions

View file

@ -1,9 +1,9 @@
;;; prelude-core.el --- Emacs Prelude: core Prelude defuns. ;;; prelude-core.el --- Emacs Prelude: Core Prelude functions.
;; ;;
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience
@ -35,8 +35,7 @@
(require 'thingatpt) (require 'thingatpt)
(defun prelude-open-with () (defun prelude-open-with ()
"Simple function that allows us to open the underlying "Open visited file in external program."
file of a buffer in an external program."
(interactive) (interactive)
(when buffer-file-name (when buffer-file-name
(shell-command (concat (shell-command (concat
@ -47,9 +46,11 @@ file of a buffer in an external program."
buffer-file-name)))) buffer-file-name))))
(defun prelude-buffer-mode (buffer-or-name) (defun prelude-buffer-mode (buffer-or-name)
"Retrieve the `major-mode' of BUFFER-OR-NAME."
(with-current-buffer buffer-or-name major-mode)) (with-current-buffer buffer-or-name major-mode))
(defun prelude-visit-term-buffer () (defun prelude-visit-term-buffer ()
"Create or visit a terminal buffer."
(interactive) (interactive)
(if (not (get-buffer "*ansi-term*")) (if (not (get-buffer "*ansi-term*"))
(progn (progn
@ -112,12 +113,12 @@ the curson at its beginning, according to the current mode."
(forward-line -1)) (forward-line -1))
(defun prelude-indent-buffer () (defun prelude-indent-buffer ()
"Indents the entire buffer." "Indent the currently visited buffer."
(interactive) (interactive)
(indent-region (point-min) (point-max))) (indent-region (point-min) (point-max)))
(defun prelude-indent-region-or-buffer () (defun prelude-indent-region-or-buffer ()
"Indents a region if selected, otherwise the whole buffer." "Indent a region if selected, otherwise the whole buffer."
(interactive) (interactive)
(save-excursion (save-excursion
(if (region-active-p) (if (region-active-p)
@ -189,7 +190,7 @@ there's a region, all lines that region covers will be duplicated."
(set-buffer-modified-p nil))))))) (set-buffer-modified-p nil)))))))
(defun prelude-delete-file-and-buffer () (defun prelude-delete-file-and-buffer ()
"Kills the current buffer and deletes the file it is visiting" "Kill the current buffer and deletes the file it is visiting."
(interactive) (interactive)
(let ((filename (buffer-file-name))) (let ((filename (buffer-file-name)))
(when filename (when filename
@ -209,6 +210,7 @@ there's a region, all lines that region covers will be duplicated."
((search-forward "<html" nil t) (html-mode))))) ((search-forward "<html" nil t) (html-mode)))))
(defun prelude-untabify-buffer () (defun prelude-untabify-buffer ()
"Remove all tabs from the current buffer."
(interactive) (interactive)
(untabify (point-min) (point-max))) (untabify (point-min) (point-max)))
@ -241,7 +243,7 @@ there's a region, all lines that region covers will be duplicated."
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))) (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
(defun prelude-switch-or-start (function buffer) (defun prelude-switch-or-start (function buffer)
"If the buffer is current, bury it, otherwise invoke the function." "If BUFFER is current, bury it, otherwise invoke FUNCTION."
(if (equal (buffer-name (current-buffer)) buffer) (if (equal (buffer-name (current-buffer)) buffer)
(bury-buffer) (bury-buffer)
(if (get-buffer buffer) (if (get-buffer buffer)
@ -249,12 +251,12 @@ there's a region, all lines that region covers will be duplicated."
(funcall function)))) (funcall function))))
(defun prelude-insert-date () (defun prelude-insert-date ()
"Insert a time-stamp according to locale's date and time format." "Insert a timestamp according to locale's date and time format."
(interactive) (interactive)
(insert (format-time-string "%c" (current-time)))) (insert (format-time-string "%c" (current-time))))
(defun prelude-conditionally-enable-paredit-mode () (defun prelude-conditionally-enable-paredit-mode ()
"Enable paredit-mode in the minibuffer, during eval-expression." "Enable `paredit-mode' in the minibuffer, during `eval-expression'."
(if (eq this-command 'eval-expression) (if (eq this-command 'eval-expression)
(paredit-mode 1))) (paredit-mode 1)))
@ -285,7 +287,8 @@ there's a region, all lines that region covers will be duplicated."
(other-window 1)) (other-window 1))
(defun prelude-kill-other-buffers () (defun prelude-kill-other-buffers ()
"Kill all buffers but the current one. Doesn't mess with special buffers." "Kill all buffers but the current one.
Doesn't mess with special buffers."
(interactive) (interactive)
(-each (-each
(->> (buffer-list) (->> (buffer-list)
@ -293,31 +296,6 @@ there's a region, all lines that region covers will be duplicated."
(--remove (eql (current-buffer) it))) (--remove (eql (current-buffer) it)))
#'kill-buffer)) #'kill-buffer))
(require 'repeat)
(defun make-repeatable-command (cmd)
"Returns a new command that is a repeatable version of CMD.
The new command is named CMD-repeat. CMD should be a quoted
command.
This allows you to bind the command to a compound keystroke andб
repeat it with just the final key. For example:
(global-set-key (kbd \"C-c a\") (make-repeatable-command 'foo))
will create a new command called foo-repeat. Typing C-c a will
just invoke foo. Typing C-c a a a will invoke foo three times,
and so on."
(fset (intern (concat (symbol-name cmd) "-repeat"))
`(lambda ,(help-function-arglist cmd) ;; arg list
,(format "A repeatable version of `%s'."
(symbol-name cmd)) ;; doc string
,(interactive-form cmd) ;; interactive form
;; see also repeat-message-function
(setq last-repeatable-command ',cmd)
(repeat nil)))
(intern (concat (symbol-name cmd) "-repeat")))
(defun prelude-create-scratch-buffer () (defun prelude-create-scratch-buffer ()
"Create a new scratch buffer." "Create a new scratch buffer."
(interactive) (interactive)
@ -338,6 +316,7 @@ and so on."
"Visit WikEmacs at http://wikemacs.org to find out even more about Emacs.")) "Visit WikEmacs at http://wikemacs.org to find out even more about Emacs."))
(defun prelude-tip-of-the-day () (defun prelude-tip-of-the-day ()
"Display a random entry from `prelude-tips'."
(interactive) (interactive)
;; pick a new random seed ;; pick a new random seed
(random t) (random t)

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience
@ -92,7 +92,6 @@
(global-set-key (kbd "C-x g") 'magit-status) (global-set-key (kbd "C-x g") 'magit-status)
(global-set-key (kbd "C-=") 'er/expand-region) (global-set-key (kbd "C-=") 'er/expand-region)
(global-set-key (kbd "C-c w") (make-repeatable-command 'er/expand-region))
;; make C-x C-x usable with transient-mark-mode ;; make C-x C-x usable with transient-mark-mode
(define-key global-map (define-key global-map

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience
;; Package-Requires: ((prelude-lisp "1.0.0")) ;; Package-Requires: ((prelude-lisp "1.0.0"))

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience

View file

@ -3,7 +3,7 @@
;; Copyright © 2011-2013 Bozhidar Batsov ;; Copyright © 2011-2013 Bozhidar Batsov
;; ;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com> ;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://batsov.com/emacs-prelude ;; URL: https://github.com/bbatsov/prelude
;; Version: 1.0.0 ;; Version: 1.0.0
;; Keywords: convenience ;; Keywords: convenience