fill and format docstrings

This commit is contained in:
Eric Danan 2016-12-12 10:29:00 +01:00
parent 4b0ca9270b
commit ea492ad5ce

View file

@ -13,15 +13,15 @@
;;; License: ;;; License:
;; This program is free software; you can redistribute it and/or modify ;; This program is free software; you can redistribute it and/or
;; it under the terms of the GNU General Public License as published by ;; modify it under the terms of the GNU General Public License as
;; the Free Software Foundation; either version 3, or (at your option) ;; published by the Free Software Foundation; either version 3, or (at
;; any later version. ;; your option) any later version.
;; ;;
;; This program is distributed in the hope that it will be useful, ;; This program is distributed in the hope that it will be useful, but
;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; GNU General Public License for more details. ;; General Public License for more details.
;; ;;
;; You should have received a copy of the GNU General Public License ;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the ;; along with GNU Emacs; see the file COPYING. If not, write to the
@ -31,10 +31,11 @@
;;; Commentary: ;;; Commentary:
;; ;;
;; Projectile has native support for using ivy as its completion ;; Projectile has native support for using ivy as its completion
;; system. Counsel-projectile provides further ivy integration into ;; system. Counsel-projectile provides further ivy integration into
;; projectile by taking advantage of ivy's mechanism to select from a ;; projectile by taking advantage of ivy's mechanism to select from a
;; list of actions and/or apply an action without leaving the comlpetion ;; list of actions and/or apply an action without leaving the
;; session. It is inspired by helm-projectile. See the README for more details. ;; comlpetion session. It is inspired by helm-projectile. See the
;; README for more details.
;; ;;
;;; Code: ;;; Code:
@ -44,13 +45,15 @@
;;; counsel-projectile-map ;;; counsel-projectile-map
(defun counsel-projectile-drop-to-switch-project () (defun counsel-projectile-drop-to-switch-project ()
"For use in minibuffer maps. Quit and call `counsel-projectile-switch-project'." "For use in minibuffer maps. Quit and call
`counsel-projectile-switch-project'."
(interactive) (interactive)
(ivy-quit-and-run (ivy-quit-and-run
(counsel-projectile-switch-project))) (counsel-projectile-switch-project)))
(defvar counsel-projectile-drop-to-switch-project-binding "M-SPC" (defvar counsel-projectile-drop-to-switch-project-binding "M-SPC"
"Key binding for `counsel-projectile-drop-to-switch-project' in `counsel-projectile-map'.") "Key binding for `counsel-projectile-drop-to-switch-project' in
`counsel-projectile-map'.")
(defvar counsel-projectile-map (defvar counsel-projectile-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
@ -65,7 +68,9 @@
(defun counsel-projectile--file-list (&optional no-buffer) (defun counsel-projectile--file-list (&optional no-buffer)
"Return a list of files for the current project. "Return a list of files for the current project.
Like `projectile-current-project-files', but fontifies non-visited file names with the `ivy-virtual' face. With optional argument NO-BUFFER, only list non-visited files." Like `projectile-current-project-files', but fontifies
non-visited file names with the `ivy-virtual' face. With optional
argument NO-BUFFER, only list non-visited files."
(let ((root (projectile-project-root))) (let ((root (projectile-project-root)))
(cl-loop (cl-loop
for name in (projectile-current-project-files) for name in (projectile-current-project-files)
@ -85,15 +90,16 @@ Like `projectile-current-project-files', but fontifies non-visited file names wi
(run-hooks 'projectile-find-file-hook)) (run-hooks 'projectile-find-file-hook))
(defun counsel-projectile--find-file-other-window-action (file) (defun counsel-projectile--find-file-other-window-action (file)
"Find FILE in another window and run `projectile-find-file-hook'." "Find FILE in another window and run
`projectile-find-file-hook'."
(counsel-projectile--find-file-action file t)) (counsel-projectile--find-file-action file t))
;;;###autoload ;;;###autoload
(defun counsel-projectile-find-file (&optional arg) (defun counsel-projectile-find-file (&optional arg)
"Jump to a project's file using completion. "Jump to a project's file using completion.
Replacement for `projectile-find-file'. Replacement for `projectile-find-file'. With a prefix ARG
With a prefix ARG invalidates the cache first." invalidates the cache first."
(interactive "P") (interactive "P")
(projectile-maybe-invalidate-cache arg) (projectile-maybe-invalidate-cache arg)
(ivy-read (projectile-prepend-project-name "Find file: ") (ivy-read (projectile-prepend-project-name "Find file: ")
@ -126,7 +132,8 @@ With a prefix ARG invalidates the cache first."
(run-hooks 'projectile-find-dir-hook)) (run-hooks 'projectile-find-dir-hook))
(defun counsel-projectile--find-dir-other-window-action (dir) (defun counsel-projectile--find-dir-other-window-action (dir)
"Visit DIR with dired in another window and run `projectile-find-dir-hook'." "Visit DIR with dired in another window and run
`projectile-find-dir-hook'."
(counsel-projectile--find-dir-action dir t)) (counsel-projectile--find-dir-action dir t))
;;;###autoload ;;;###autoload
@ -153,13 +160,15 @@ With a prefix ARG invalidates the cache first."
(defun counsel-projectile--buffer-list () (defun counsel-projectile--buffer-list ()
"Get a list of project buffer names. "Get a list of project buffer names.
Like `projectile-project-buffer-names', but propertize buffer names as in `ivy--buffer-list'." Like `projectile-project-buffer-names', but propertize buffer
names as in `ivy--buffer-list'."
(ivy--buffer-list "" nil (ivy--buffer-list "" nil
(lambda (x) (lambda (x)
(member (car x) (projectile-project-buffer-names))))) (member (car x) (projectile-project-buffer-names)))))
(defun counsel-projectile--switch-buffer-action (buffer &optional other-window) (defun counsel-projectile--switch-buffer-action (buffer &optional other-window)
"Switch to BUFFER. "Switch to BUFFER.
BUFFER may be a string or nil." BUFFER may be a string or nil."
(cond (cond
((zerop (length buffer)) ((zerop (length buffer))
@ -171,6 +180,7 @@ BUFFER may be a string or nil."
(defun counsel-projectile--switch-buffer-other-window-action (buffer) (defun counsel-projectile--switch-buffer-other-window-action (buffer)
"Switch to BUFFER in other window. "Switch to BUFFER in other window.
BUFFER may be a string or nil." BUFFER may be a string or nil."
(counsel-projectile--switch-buffer-action buffer t)) (counsel-projectile--switch-buffer-action buffer t))
@ -229,8 +239,11 @@ BUFFER may be a string or nil."
;;;###autoload ;;;###autoload
(defun counsel-projectile-switch-project (&optional arg) (defun counsel-projectile-switch-project (&optional arg)
"Switch to a project we have visited before. "Switch to a project we have visited before.
Invokes the command referenced by `projectile-switch-project-action' on switch.
With a prefix ARG invokes `projectile-commander' instead of `projectile-switch-project-action.'" Invokes the command referenced by
`projectile-switch-project-action' on switch. With a prefix ARG
invokes `projectile-commander' instead of
`projectile-switch-project-action.'"
(interactive "P") (interactive "P")
(ivy-read (projectile-prepend-project-name "Switch to project: ") (ivy-read (projectile-prepend-project-name "Switch to project: ")
projectile-known-projects projectile-known-projects
@ -299,6 +312,7 @@ With a prefix ARG invokes `projectile-commander' instead of `projectile-switch-p
(defun counsel-projectile--transformer (str) (defun counsel-projectile--transformer (str)
"Fontifies modified, file-visiting buffers. "Fontifies modified, file-visiting buffers.
Relies on `ivy-switch-buffer-transformer'." Relies on `ivy-switch-buffer-transformer'."
(if (eq (get-text-property 0 'type str) 'buffer) (if (eq (get-text-property 0 'type str) 'buffer)
(ivy-switch-buffer-transformer str) (ivy-switch-buffer-transformer str)
@ -306,7 +320,9 @@ Relies on `ivy-switch-buffer-transformer'."
(defun counsel-projectile--matcher (regexp candidates) (defun counsel-projectile--matcher (regexp candidates)
"Return REGEXP-matching CANDIDATES. "Return REGEXP-matching CANDIDATES.
Relies on `ivy--switch-buffer-matcher` and `counsel--find-file-matcher'."
Relies on `ivy--switch-buffer-matcher` and
`counsel--find-file-matcher'."
(let ((buffers (cl-remove-if-not (lambda (name) (let ((buffers (cl-remove-if-not (lambda (name)
(eq (get-text-property 0 'type name) 'buffer)) (eq (get-text-property 0 'type name) 'buffer))
candidates)) candidates))