emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 94a466f 341/348: ivy.el: Clean up whitespace


From: Oleh Krehel
Subject: [elpa] master 94a466f 341/348: ivy.el: Clean up whitespace
Date: Sat, 8 Apr 2017 11:04:27 -0400 (EDT)

branch: master
commit 94a466f5743b6a9f14152cff8bab6691817d97e1
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el: Clean up whitespace
---
 ivy.el | 163 +++++++++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 97 insertions(+), 66 deletions(-)

diff --git a/ivy.el b/ivy.el
index f6e43f8..e362b7f 100644
--- a/ivy.el
+++ b/ivy.el
@@ -457,7 +457,7 @@ When non-nil, it should contain at least one %d.")
   "Number of groups in the current `ivy--regex'.")
 
 (defvar ivy--full-length nil
-  "When :dynamic-collection is non-nil, this can be the total amount of 
candidates.")
+  "The total amount of candidates when :dynamic-collection is non-nil.")
 
 (defvar ivy--old-text ""
   "Store old `ivy-text' for dynamic completion.")
@@ -615,8 +615,8 @@ selection, non-nil otherwise."
   (setq ivy-current-prefix-arg current-prefix-arg)
   (let ((actions (copy-sequence (ivy-state-action ivy-last))))
     (unwind-protect
-        (when (ivy-read-action)
-          (ivy-call))
+         (when (ivy-read-action)
+           (ivy-call))
       (ivy-set-action actions)))
   (ivy-shrink-after-dispatching))
 
@@ -1012,14 +1012,19 @@ Example use:
                     ;; Alist type.
                     ((and (consp collection)
                           (consp (car collection))
-                          ;; Previously, the cdr of the selected candidate 
would be returned.
-                          ;; Now, the whole candidate is returned.
+                          ;; Previously, the cdr of the selected
+                          ;; candidate would be returned.  Now, the
+                          ;; whole candidate is returned.
                           (let (idx)
-                            (if (setq idx (get-text-property 0 'idx 
(ivy-state-current ivy-last)))
+                            (if (setq idx (get-text-property
+                                           0 'idx (ivy-state-current 
ivy-last)))
                                 (nth idx collection)
-                              (assoc (ivy-state-current ivy-last) 
collection)))))
+                              (assoc (ivy-state-current ivy-last)
+                                     collection)))))
                     (ivy--directory
-                     (expand-file-name (ivy-state-current ivy-last) 
ivy--directory))
+                     (expand-file-name
+                      (ivy-state-current ivy-last)
+                      ivy--directory))
                     ((equal (ivy-state-current ivy-last) "")
                      ivy-text)
                     (t
@@ -1404,7 +1409,8 @@ Directories come first."
                     &key
                       predicate require-match initial-input
                       history preselect keymap update-fn sort
-                      action unwind re-builder matcher dynamic-collection 
caller)
+                      action unwind re-builder matcher
+                      dynamic-collection caller)
   "Read a string in the minibuffer, with completion.
 
 PROMPT is a format string, normally ending in a colon and a
@@ -1487,8 +1493,9 @@ customizations apply to the current completion session."
          (plist-get ivy--display-transformers-list
                     (or caller (and (functionp collection)
                                     collection))))
-        (ivy-display-function (unless (window-minibuffer-p)
-                                (cdr (assoc caller 
ivy-display-functions-alist)))))
+        (ivy-display-function
+         (unless (window-minibuffer-p)
+           (cdr (assoc caller ivy-display-functions-alist)))))
     (setq ivy-last
           (make-ivy-state
            :prompt prompt
@@ -1520,10 +1527,11 @@ customizations apply to the current completion session."
                (let* ((hist (or history 'ivy-history))
                       (minibuffer-completion-table collection)
                       (minibuffer-completion-predicate predicate)
-                      (resize-mini-windows (cond
-                                             ((display-graphic-p) nil)
-                                             ((null resize-mini-windows) 
'grow-only)
-                                             (t resize-mini-windows))))
+                      (resize-mini-windows
+                       (cond
+                         ((display-graphic-p) nil)
+                         ((null resize-mini-windows) 'grow-only)
+                         (t resize-mini-windows))))
                  (read-from-minibuffer
                   prompt
                   (ivy-state-initial-input ivy-last)
@@ -1610,19 +1618,26 @@ This is useful for recursive `ivy-read'."
                         (not (equal initial-input "")))
                (cond ((file-directory-p initial-input)
                       (when (and (eq this-command 'dired-do-copy)
-                                 (equal (file-name-nondirectory initial-input) 
""))
+                                 (equal (file-name-nondirectory initial-input)
+                                        ""))
                         (setf (ivy-state-preselect state) (setq preselect 
nil)))
                       (setq ivy--directory initial-input)
                       (setq initial-input nil)
                       (when preselect
-                        (let ((preselect-directory (file-name-directory 
preselect)))
+                        (let ((preselect-directory
+                               (file-name-directory preselect)))
                           (when (and preselect-directory
-                                     (not (equal (expand-file-name 
preselect-directory)
-                                                 (expand-file-name 
ivy--directory))))
-                            (setf (ivy-state-preselect state) (setq preselect 
nil))))))
-                     ((ignore-errors (file-exists-p (file-name-directory 
initial-input)))
+                                     (not (equal
+                                           (expand-file-name
+                                            preselect-directory)
+                                           (expand-file-name ivy--directory))))
+                            (setf (ivy-state-preselect state)
+                                  (setq preselect nil))))))
+                     ((ignore-errors
+                        (file-exists-p (file-name-directory initial-input)))
                       (setq ivy--directory (file-name-directory initial-input))
-                      (setf (ivy-state-preselect state) 
(file-name-nondirectory initial-input)))))
+                      (setf (ivy-state-preselect state)
+                            (file-name-nondirectory initial-input)))))
              (require 'dired)
              (when preselect
                (let ((preselect-directory (file-name-directory preselect)))
@@ -1727,7 +1742,7 @@ This is useful for recursive `ivy-read'."
          prompt)
         ((null ivy-count-format)
          (error
-          "`ivy-count-format' can't be nil.  Set it to an empty string 
instead"))
+          "`ivy-count-format' can't be nil.  Set it to \"\" instead"))
         ((string-match "%d.*%d" ivy-count-format)
          (let ((w (length (number-to-string
                            (length ivy--all-candidates))))
@@ -1841,9 +1856,11 @@ The previous string is between `ivy-completion-beg' and 
`ivy-completion-end'."
         (len (length str))
         face-sym)
     (while (and (<= pos len)
-                (let ((prop (or (prog1 (get-text-property pos 'face str)
+                (let ((prop (or (prog1 (get-text-property
+                                        pos 'face str)
                                   (setq face-sym 'face))
-                                (prog1 (get-text-property pos 'font-lock-face 
str)
+                                (prog1 (get-text-property
+                                        pos 'font-lock-face str)
                                   (setq face-sym 'font-lock-face)))))
                   (not (eq 'completions-common-part
                            (if (listp prop) (car prop) prop)))))
@@ -2231,7 +2248,9 @@ The returned value should be the updated PROMPT.")
             (setq n-str (concat n-str "\n")))
           (let ((regex (format "\\([^\n]\\{%d\\}\\)[^\n]" (window-width))))
             (while (string-match regex n-str)
-              (setq n-str (replace-match (concat (match-string 1 n-str) "\n") 
nil t n-str 1))))
+              (setq n-str (replace-match
+                           (concat (match-string 1 n-str) "\n")
+                           nil t n-str 1))))
           (set-text-properties 0 (length n-str)
                                `(face minibuffer-prompt ,@std-props)
                                n-str)
@@ -2293,7 +2312,8 @@ If SUBEXP is nil, the text properties are applied to the 
whole match."
                  (not (equal (ivy-state-current ivy-last) ""))
                  (file-directory-p (ivy-state-current ivy-last))
                  (file-exists-p (ivy-state-current ivy-last)))))
-         (ivy--cd (expand-file-name (ivy-state-current ivy-last) 
ivy--directory)))))
+         (ivy--cd
+          (expand-file-name (ivy-state-current ivy-last) ivy--directory)))))
 
 (defcustom ivy-magic-tilde t
   "When non-nil, ~ will move home when selecting files.
@@ -2377,9 +2397,11 @@ Should be run via minibuffer `post-command-hook'."
           (let ((text-height (cdr (window-text-pixel-size)))
                 (body-height (window-body-height nil t)))
             (when (> text-height body-height)
-              ;; Note: the size increment needs to be at least 
frame-char-height,
-              ;; otherwise resizing won't do anything.
-              (let ((delta (max (- text-height body-height) 
(frame-char-height))))
+              ;; Note: the size increment needs to be at least
+              ;; frame-char-height, otherwise resizing won't do
+              ;; anything.
+              (let ((delta (max (- text-height body-height)
+                                (frame-char-height))))
                 (window-resize nil delta nil t t))))
         (let ((text-height (count-screen-lines))
               (body-height (window-body-height)))
@@ -2489,7 +2511,8 @@ CANDIDATES are assumed to be static."
                           ivy--old-cands)))
                       (t
                        (ivy--re-filter re candidates)))))
-        (if (memq (cdr (assoc (ivy-state-caller ivy-last) 
ivy-index-functions-alist))
+        (if (memq (cdr (assoc (ivy-state-caller ivy-last)
+                              ivy-index-functions-alist))
                   '(ivy-recompute-index-swiper
                     ivy-recompute-index-swiper-async))
             (progn
@@ -2519,8 +2542,9 @@ CANDIDATES are assumed to be static."
                    res))))
     (setq ivy--all-candidates res)))
 
-(defcustom ivy-sort-matches-functions-alist '((t . nil)
-                                              (ivy-switch-buffer . 
ivy-sort-function-buffer))
+(defcustom ivy-sort-matches-functions-alist
+  '((t . nil)
+    (ivy-switch-buffer . ivy-sort-function-buffer))
   "An alist of functions for sorting matching candidates.
 
 Unlike `ivy-sort-functions-alist', which is used to sort the
@@ -2605,14 +2629,14 @@ before substring matches."
         (setq re-prefix (concat "^" base-re)))
       (dolist (s candidates)
         (cond
-         ((and (assoc s ivy--virtual-buffers) (string-match re-prefix s))
-          (push s res-virtual-prefix))
-         ((assoc s ivy--virtual-buffers)
-          (push s res-virtual-noprefix))
-         ((string-match re-prefix s)
-          (push s res-prefix))
-         (t
-          (push s res-noprefix))))
+          ((and (assoc s ivy--virtual-buffers) (string-match re-prefix s))
+           (push s res-virtual-prefix))
+          ((assoc s ivy--virtual-buffers)
+           (push s res-virtual-noprefix))
+          ((string-match re-prefix s)
+           (push s res-prefix))
+          (t
+           (push s res-noprefix))))
       (nconc
        (nreverse res-prefix)
        (nreverse res-noprefix)
@@ -2744,7 +2768,8 @@ no sorting is done.")
 (defun ivy--flx-sort (name cands)
   "Sort according to closeness to string NAME the string list CANDS."
   (condition-case nil
-      (let* (;; an optimized regex for fuzzy matching
+      (let* (
+             ;; an optimized regex for fuzzy matching
              ;; "abc" → "\\`[^a]*a[^b]*b[^c]*c"
              (fuzzy-regex (if (= (elt name 0) ?^)
                               (concat "^"
@@ -2920,7 +2945,8 @@ SEPARATOR is used to join the candidates."
                          ((zerop i)
                           (car ivy-minibuffer-faces))
                          (t
-                          (nth (1+ (mod (+ i 2) (1- (length 
ivy-minibuffer-faces))))
+                          (nth (1+ (mod (+ i 2)
+                                        (1- (length ivy-minibuffer-faces))))
                                ivy-minibuffer-faces)))))
               (ivy-add-face-text-property
                (match-beginning i) (match-end i)
@@ -2989,13 +3015,15 @@ CANDS is a list of strings."
         virtual-buffers)
     (dolist (head (append
                    (copy-sequence recentf-list)
-                   (delq nil (mapcar (lambda (bookmark)
-                                       (let (file)
-                                         (when (setq file (assoc 'filename 
bookmark))
-                                           (unless (string= (cdr file) "   - 
no file -")
-                                             (cons (car bookmark)
-                                                   (cdr file))))))
-                                     bookmarks))))
+                   (delq nil (mapcar
+                              (lambda (bookmark)
+                                (let (file)
+                                  (when (setq file (assoc 'filename bookmark))
+                                    (unless (string= (cdr file)
+                                                     "   - no file -")
+                                      (cons (car bookmark)
+                                            (cdr file))))))
+                              bookmarks))))
       (let ((file-name (if (stringp head)
                            head
                          (cdr head)))
@@ -3007,7 +3035,8 @@ CANDS is a list of strings."
         (when (equal name "")
           (if (consp head)
               (setq name (car head))
-            (setq name (file-name-nondirectory (directory-file-name 
file-name)))))
+            (setq name (file-name-nondirectory
+                        (directory-file-name file-name)))))
         (and (not (equal name ""))
              (null (get-file-buffer file-name))
              (not (assoc name virtual-buffers))
@@ -3114,20 +3143,21 @@ Currently, the split configuration (i.e. horizonal or 
vertical)
 and point positions are saved, but the split positions aren't.
 Use `ivy-pop-view' to delete any item from `ivy-views'."
   (interactive)
-  (let* ((view (cl-labels ((ft (tr)
-                             (if (consp tr)
-                                 (if (eq (car tr) t)
-                                     (cons 'vert
-                                           (mapcar #'ft (cddr tr)))
-                                   (cons 'horz
-                                         (mapcar #'ft (cddr tr))))
-                               (with-current-buffer (window-buffer tr)
-                                 (cond ((buffer-file-name)
-                                        (list 'file (buffer-file-name) 
(point)))
-                                       ((eq major-mode 'dired-mode)
-                                        (list 'file default-directory (point)))
-                                       (t
-                                        (list 'buffer (buffer-name) 
(point))))))))
+  (let* ((view (cl-labels
+                   ((ft (tr)
+                      (if (consp tr)
+                          (if (eq (car tr) t)
+                              (cons 'vert
+                                    (mapcar #'ft (cddr tr)))
+                            (cons 'horz
+                                  (mapcar #'ft (cddr tr))))
+                        (with-current-buffer (window-buffer tr)
+                          (cond ((buffer-file-name)
+                                 (list 'file (buffer-file-name) (point)))
+                                ((eq major-mode 'dired-mode)
+                                 (list 'file default-directory (point)))
+                                (t
+                                 (list 'buffer (buffer-name) (point))))))))
                  (ft (car (window-tree)))))
          (view-name (ivy-read "Name view: " nil
                               :initial-input (ivy-default-view-name))))
@@ -3632,7 +3662,8 @@ EVENT gives the mouse position."
                (selected-window))
               (when (timerp ivy-occur-timer)
                 (cancel-timer ivy-occur-timer))
-              (setq ivy-occur-timer (run-at-time 1.0 nil 
'swiper--cleanup))))))))
+              (setq ivy-occur-timer
+                    (run-at-time 1.0 nil 'swiper--cleanup))))))))
 
 (defun ivy-occur-press-and-switch ()
   (interactive)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]