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

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

[elpa] master 269e61a 17/17: Merge commit 'cc38c044a13e6df822431d6c706cf


From: Oleh Krehel
Subject: [elpa] master 269e61a 17/17: Merge commit 'cc38c044a13e6df822431d6c706cf4b9255900bd' from ace-window
Date: Fri, 08 May 2015 13:43:44 +0000

branch: master
commit 269e61a53a87ce7e1e93753534bcbe75ee1b4c5c
Merge: 876d210 cc38c04
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Merge commit 'cc38c044a13e6df822431d6c706cf4b9255900bd' from ace-window
    
    Move the dependencies into a new ELPA package avy.
---
 packages/ace-window/Cask          |    8 +
 packages/ace-window/Makefile      |   15 +-
 packages/ace-window/ace-window.el |   19 +--
 packages/ace-window/avy-jump.el   |  288 -------------------------------------
 packages/ace-window/avy-test.el   |   68 ---------
 packages/ace-window/avy.el        |  117 ---------------
 6 files changed, 22 insertions(+), 493 deletions(-)

diff --git a/packages/ace-window/Cask b/packages/ace-window/Cask
new file mode 100644
index 0000000..5526c3c
--- /dev/null
+++ b/packages/ace-window/Cask
@@ -0,0 +1,8 @@
+(source gnu)
+(source melpa)
+
+(package-file "ace-window.el")
+
+(development
+ (depends-on "avy"))
+
diff --git a/packages/ace-window/Makefile b/packages/ace-window/Makefile
index 4f0a640..8dff696 100644
--- a/packages/ace-window/Makefile
+++ b/packages/ace-window/Makefile
@@ -1,14 +1,15 @@
-EMACS = emacs
-# EMACS = emacs-24.3
+emacs ?= emacs
+CASK = ~/.cask/bin/cask
 
-LOAD = -l avy.el -l avy-test.el
+.PHONY: all clean
 
-.PHONY: all test clean
+all: compile
 
-all: test
+cask:
+       $(shell EMACS=$(emacs) $(CASK) --verbose --debug)
 
-test:
-       $(EMACS) -batch $(LOAD) -f ert-run-tests-batch-and-exit
+compile:
+       $(CASK) exec $(emacs) -batch --eval "(byte-compile-file 
\"ace-window.el\")"
 
 clean:
        rm -f *.elc
diff --git a/packages/ace-window/ace-window.el 
b/packages/ace-window/ace-window.el
index 68e28cf..f34a77a 100644
--- a/packages/ace-window/ace-window.el
+++ b/packages/ace-window/ace-window.el
@@ -5,7 +5,8 @@
 ;; Author: Oleh Krehel <address@hidden>
 ;; Maintainer: Oleh Krehel <address@hidden>
 ;; URL: https://github.com/abo-abo/ace-window
-;; Version: 0.8.0
+;; Version: 0.8.1
+;; Package-Requires: ((avy "0.1.0"))
 ;; Keywords: window, location
 
 ;; This file is part of GNU Emacs.
@@ -59,7 +60,7 @@
 ;; deleted instead.
 
 ;;; Code:
-(require 'avy)
+(require 'avy-jump)
 (require 'ring)
 
 ;;* Customization
@@ -141,9 +142,6 @@ Use M-0 `ace-window' to toggle this value."
        (error "Invalid `aw-scope': %S" aw-scope))))
    'aw-window<))
 
-(defvar aw-overlays-lead nil
-  "Hold overlays for leading chars.")
-
 (defvar aw-overlays-back nil
   "Hold overlays for when `aw-background' is t.")
 
@@ -163,7 +161,7 @@ Use M-0 `ace-window' to toggle this value."
   ;; background
   (mapc #'delete-overlay aw-overlays-back)
   (setq aw-overlays-back nil)
-  (aw--remove-leading-chars))
+  (avy--remove-leading-chars))
 
 (defun aw--lead-overlay (path leaf)
   "Create an overlay using PATH at LEAF.
@@ -197,12 +195,7 @@ LEAF is (PT . WND)."
     (overlay-put ol 'face 'aw-leading-char-face)
     (overlay-put ol 'window wnd)
     (overlay-put ol 'display new-str)
-    (push ol aw-overlays-lead)))
-
-(defun aw--remove-leading-chars ()
-  "Remove leading char overlays."
-  (mapc #'delete-overlay aw-overlays-lead)
-  (setq aw-overlays-lead nil))
+    (push ol avy--overlays-lead)))
 
 (defun aw--make-backgrounds (wnd-list)
   "Create a dim background overlay for each window on WND-LIST."
@@ -265,7 +258,7 @@ Amend MODE-LINE to the mode line for the duration of the 
selection."
               (condition-case err
                   (or (cdr (avy-read (avy-tree candidate-list aw-keys)
                                      #'aw--lead-overlay
-                                     #'aw--remove-leading-chars))
+                                     #'avy--remove-leading-chars))
                       start-window)
                 (error
                  (if (memq (nth 2 err) aw--flip-keys)
diff --git a/packages/ace-window/avy-jump.el b/packages/ace-window/avy-jump.el
deleted file mode 100644
index 50c7fce..0000000
--- a/packages/ace-window/avy-jump.el
+++ /dev/null
@@ -1,288 +0,0 @@
-;;; avy-jump.el --- jump to things tree-style
-
-;; Copyright (C) 2015  Free Software Foundation, Inc.
-
-;; Author: Oleh Krehel
-
-;; This file is part of GNU Emacs.
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; For a full copy of the GNU General Public License
-;; see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; This package offers various commands for navigating to things using `avy'.
-;; They are in the "Commands" outline.
-
-;;; Code:
-;;* Requires
-(require 'avy)
-(require 'ace-window)
-
-;;* Customization
-(defgroup avy-jump nil
-  "Jump to things tree-style."
-  :group 'convenience
-  :prefix "avi-")
-
-(defcustom avi-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
-  "Keys for jumping.")
-
-(defcustom avi-background nil
-  "When non-nil, a gray background will be added during the selection."
-  :type 'boolean)
-
-(defface avi-lead-face
-  '((t (:foreground "white" :background "#e52b50")))
-  "Face used for the leading chars.")
-
-;;* Internals
-(defun avi--goto (x)
-  "Goto X.
-X is (POS . WND)
-POS is either a position or (BEG . END)."
-  (if (null x)
-      (message "zero candidates")
-    (select-window (cdr x))
-    (let ((pt (car x)))
-      (when (consp pt)
-        (setq pt (car pt)))
-      (goto-char pt))))
-
-(defun avi--process (candidates overlay-fn)
-  "Select one of CANDIDATES using `avy-read'."
-  (unwind-protect
-       (let ((aw-background avi-background))
-         (cl-case (length candidates)
-           (0
-            nil)
-           (1
-            (car candidates))
-           (t
-            (aw--make-backgrounds (list (selected-window)))
-            (avy-read (avy-tree candidates avi-keys)
-                      overlay-fn
-                      #'aw--remove-leading-chars))))
-    (aw--done)))
-
-(defun avi--regex-candidates (regex &optional wnd beg end pred)
-  "Return all elements that match REGEX in WND.
-Each element of the list is ((BEG . END) . WND)
-When PRED is non-nil, it's a filter for matching point positions."
-  (setq wnd (or wnd (selected-window)))
-  (let ((we (or end (window-end (selected-window) t)))
-        candidates)
-    (save-window-excursion
-      (select-window wnd)
-      (save-excursion
-        (goto-char (or beg (window-start)))
-        (while (re-search-forward regex we t)
-          (when (or (null pred)
-                    (funcall pred))
-            (push (cons (cons (match-beginning 0)
-                              (match-end 0))
-                        wnd) candidates))))
-      (nreverse candidates))))
-
-(defvar avi--overlay-offset 0
-  "The offset to apply in `avi--overlay'.")
-
-(defun avi--overlay (str pt wnd)
-  "Create an overlay with STR at PT in WND."
-  (let* ((pt (+ pt avi--overlay-offset))
-         (ol (make-overlay pt (1+ pt) (window-buffer wnd)))
-         (old-str (with-selected-window wnd
-                    (buffer-substring pt (1+ pt)))))
-    (when avi-background
-      (setq old-str (propertize
-                     old-str 'face 'aw-background-face)))
-    (overlay-put ol 'window wnd)
-    (overlay-put ol 'display (concat str old-str))
-    (push ol aw-overlays-lead)))
-
-(defun avi--overlay-pre (path leaf)
-  "Create an overlay with STR at LEAF.
-PATH is a list of keys from tree root to LEAF.
-LEAF is ((BEG . END) . WND)."
-  (avi--overlay
-   (propertize (apply #'string (reverse path))
-               'face 'avi-lead-face)
-   (if (consp (car leaf))
-       (caar leaf)
-     (car leaf))
-   (cdr leaf)))
-
-(defun avi--overlay-at (path leaf)
-  "Create an overlay with STR at LEAF.
-PATH is a list of keys from tree root to LEAF.
-LEAF is ((BEG . END) . WND)."
-  (let ((str (propertize
-              (string (car (last path)))
-              'face 'avi-lead-face))
-        (pt (if (consp (car leaf))
-                (caar leaf)
-              (car leaf)))
-        (wnd (cdr leaf)))
-    (let ((ol (make-overlay pt (1+ pt)
-                            (window-buffer wnd)))
-          (old-str (with-selected-window wnd
-                     (buffer-substring pt (1+ pt)))))
-      (when avi-background
-        (setq old-str (propertize
-                       old-str 'face 'aw-background-face)))
-      (overlay-put ol 'window wnd)
-      (overlay-put ol 'display str)
-      (push ol aw-overlays-lead))))
-
-(defun avi--overlay-post (path leaf)
-  "Create an overlay with STR at LEAF.
-PATH is a list of keys from tree root to LEAF.
-LEAF is ((BEG . END) . WND)."
-  (avi--overlay
-   (propertize (apply #'string (reverse path))
-               'face 'avi-lead-face)
-   (if (consp (car leaf))
-       (cdar leaf)
-     (car leaf))
-   (cdr leaf)))
-
-;;* Commands
-;;;###autoload
-(defun avi-goto-char ()
-  "Read one char and jump to it in current window."
-  (interactive)
-  (avi--goto
-   (avi--process
-    (avi--regex-candidates
-     (string (read-char "char: "))
-     (selected-window))
-    #'avi--overlay-post)))
-
-;;;###autoload
-(defun avi-goto-char-2 ()
-  "Read two chars and jump to them in current window."
-  (interactive)
-  (avi--goto
-   (avi--process
-    (avi--regex-candidates
-     (string
-      (read-char "char 1: ")
-      (read-char "char 2: "))
-     (selected-window))
-    #'avi--overlay-post)))
-
-;;;###autoload
-(defun avi-isearch ()
-  "Jump to one of the current isearch candidates."
-  (interactive)
-  (let* ((candidates
-          (avi--regex-candidates isearch-string))
-         (avi-background nil)
-         (candidate
-          (avi--process candidates #'avi--overlay-post)))
-    (isearch-done)
-    (avi--goto candidate)))
-
-;;;###autoload
-(defun avi-goto-word-0 ()
-  "Jump to a word start in current window."
-  (interactive)
-  (let* ((avi-keys (number-sequence ?a ?z))
-         (candidates (avi--regex-candidates "\\b\\sw")))
-    (avi--goto
-     (avi--process candidates #'avi--overlay-pre))))
-
-;;;###autoload
-(defun avi-goto-word-1 ()
-  "Jump to a word start in current window.
-Read one char with which the word should start."
-  (interactive)
-  (let ((candidates (avi--regex-candidates
-                     (concat
-                      "\\b"
-                      (string (read-char "char: "))))))
-    (avi--goto
-     (avi--process candidates #'avi--overlay-pre))))
-
-(defun avi--line ()
-  "Select line in current window."
-  (let ((avi-background nil)
-        candidates)
-    (save-excursion
-      (save-restriction
-        (narrow-to-region (window-start) (window-end (selected-window) t))
-        (goto-char (point-min))
-        (while (< (point) (point-max))
-          (push (cons (point) (selected-window))
-                candidates)
-          (forward-line 1))))
-    (avi--process (nreverse candidates) #'avi--overlay-pre)))
-
-;;;###autoload
-(defun avi-goto-line ()
-  "Jump to a line start in current buffer."
-  (interactive)
-  (avi--goto (avi--line)))
-
-;;;###autoload
-(defun avi-copy-line (arg)
-  "Copy a selected line above the current line.
-ARG lines can be used."
-  (interactive "p")
-  (let ((start (car (avi--line))))
-    (move-beginning-of-line nil)
-    (save-excursion
-      (insert
-       (buffer-substring-no-properties
-        start
-        (save-excursion
-          (goto-char start)
-          (move-end-of-line arg)
-          (point)))
-       "\n"))))
-
-;;;###autoload
-(defun avi-move-line (arg)
-  "Move a selected line above the current line.
-ARG lines can be used."
-  (interactive "p")
-  (let ((start (car (avi--line))))
-    (move-beginning-of-line nil)
-    (save-excursion
-      (save-excursion
-        (goto-char start)
-        (move-end-of-line arg)
-        (kill-region start (point)))
-      (insert
-       (current-kill 0)))))
-
-;;;###autoload
-(defun avi-copy-region ()
-  "Select two lines and copy the text between them here."
-  (interactive)
-  (let ((beg (car (avi--line)))
-        (end (car (avi--line)))
-        (pad (if (bolp) "" "\n")))
-    (move-beginning-of-line nil)
-    (save-excursion
-      (insert
-       (buffer-substring-no-properties
-        beg
-        (save-excursion
-          (goto-char end)
-          (line-end-position)))
-       pad))))
-
-(provide 'avy-jump)
-
-;;; avy-jump.el ends here
diff --git a/packages/ace-window/avy-test.el b/packages/ace-window/avy-test.el
deleted file mode 100644
index 339d8a0..0000000
--- a/packages/ace-window/avy-test.el
+++ /dev/null
@@ -1,68 +0,0 @@
-;;; avy-test.el --- Tests for avy
-
-;; Copyright (C) 2015  Free Software Foundation, Inc.
-
-;; Author: Oleh Krehel
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-
-;;; Code:
-
-(require 'ert)
-(require 'avy)
-
-(ert-deftest avy-subdiv ()
-  (should
-   (equal (avy-subdiv 5 4)
-          '(1 1 1 2)))
-  (should
-   (equal (avy-subdiv 10 4)
-          '(1 1 4 4)))
-  (should
-   (equal (avy-subdiv 16 4)
-          '(4 4 4 4)))
-  (should
-   (equal (avy-subdiv 17 4)
-          '(4 4 4 5)))
-  (should
-   (equal (avy-subdiv 27 4)
-          '(4 4 4 15)))
-  (should
-   (equal (avy-subdiv 50 4)
-          '(4 14 16 16)))
-  (should
-   (equal (avy-subdiv 65 4)
-          '(16 16 16 17))))
-
-(ert-deftest avy-tree ()
-  (should
-   (equal
-    (avy-tree '(0 1 2 3 4 5 6 7 8 9 10)
-              '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
-    '((97 leaf . 0)
-      (115 leaf . 1)
-      (100 leaf . 2)
-      (102 leaf . 3)
-      (103 leaf . 4)
-      (104 leaf . 5)
-      (106 leaf . 6)
-      (107 leaf . 7)
-      (108 (97 leaf . 8)
-       (115 leaf . 9)
-       (100 leaf . 10))))))
diff --git a/packages/ace-window/avy.el b/packages/ace-window/avy.el
deleted file mode 100644
index 2f7d086..0000000
--- a/packages/ace-window/avy.el
+++ /dev/null
@@ -1,117 +0,0 @@
-;;; avy.el --- set-based completion -*- lexical-binding: t -*-
-
-;; Copyright (C) 2015  Free Software Foundation, Inc.
-
-;; Author: Oleh Krehel
-
-;; This file is part of GNU Emacs.
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; For a full copy of the GNU General Public License
-;; see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; Given a LIST and KEYS, `avy-tree' will build a balanced tree of
-;; degree B, where B is the length of KEYS.
-;;
-;; The corresponding member of KEYS is placed in each internal node of
-;; the tree.  The leafs are the members of LIST.  They can be obtained
-;; in the original order by traversing the tree depth-first.
-
-;;; Code:
-
-(defmacro avy-multipop (lst n)
-  "Remove LST's first N elements and return them."
-  `(if (<= (length ,lst) ,n)
-       (prog1 ,lst
-         (setq ,lst nil))
-     (prog1 ,lst
-       (setcdr
-        (nthcdr (1- ,n) (prog1 ,lst (setq ,lst (nthcdr ,n ,lst))))
-        nil))))
-
-(defun avy-tree (lst keys)
-  "Coerce LST into a balanced tree.
-The degree of the tree is the length of KEYS.
-KEYS are placed appropriately on internal nodes."
-  (let ((len (length keys)))
-    (cl-labels
-        ((rd (ls)
-           (let ((ln (length ls)))
-             (if (< ln len)
-                 (cl-pairlis keys
-                             (mapcar (lambda (x) (cons 'leaf x)) ls))
-               (let ((ks (copy-sequence keys))
-                     res)
-                 (dolist (s (avy-subdiv ln len))
-                   (push (cons (pop ks)
-                               (if (eq s 1)
-                                   (cons 'leaf (pop ls))
-                                 (rd (avy-multipop ls s))))
-                         res))
-                 (nreverse res))))))
-      (rd lst))))
-
-(defun avy-subdiv (n b)
-  "Distribute N in B terms in a balanced way."
-  (let* ((p (1- (floor (log n b))))
-         (x1 (expt b p))
-         (x2 (* b x1))
-         (delta (- n x2))
-         (n2 (/ delta (- x2 x1)))
-         (n1 (- b n2 1)))
-    (append
-     (make-list n1 x1)
-     (list
-      (- n (* n1 x1) (* n2 x2)))
-     (make-list n2 x2))))
-
-(defun avy-traverse (tree walker &optional recur-key)
-  "Traverse TREE generated by `avy-tree'.
-WALKER is a function that takes KEYS and LEAF.
-
-RECUR-KEY is used in recursion.
-
-LEAF is a member of LST argument of `avy-tree'.
-
-KEYS is the path from the root of `avy-tree' to LEAF."
-  (dolist (br tree)
-    (let ((key (cons (car br) recur-key)))
-      (if (eq (cadr br) 'leaf)
-          (funcall walker key (cddr br))
-        (avy-traverse (cdr br) walker key)))))
-
-(defun avy-read (tree display-fn cleanup-fn)
-  "Select a leaf from TREE using consecutive `read-char'.
-
-DISPLAY-FN should take CHAR and LEAF and signify that LEAFs
-associated with CHAR will be selected if CHAR is pressed.  This is
-commonly done by adding a CHAR overlay at LEAF position.
-
-CLEANUP-FN should take no arguments and remove the effects of
-multiple DISPLAY-FN invokations."
-  (catch 'done
-    (while tree
-      (avy-traverse tree display-fn)
-      (let ((char (read-char))
-            branch)
-        (funcall cleanup-fn)
-        (if (setq branch (assoc char tree))
-            (if (eq (car (setq tree (cdr branch))) 'leaf)
-                (throw 'done (cdr tree)))
-          (signal 'user-error (list "No such candidate" char))
-          (throw 'done nil))))))
-
-(provide 'avy)
-
-;;; avy.el ends here



reply via email to

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