Fixup the last commit and add contribution guidelines

* avy.el (avy-goto-char):
(avy-goto-char-2):
(avy-goto-word-1):
(avy-goto-subword-1):
(avy-goto-word-or-subword-1): Update argument list and docstring.

* README.md: Add a "Contributing" section.

Re #44
This commit is contained in:
Oleh Krehel 2015-05-17 12:36:37 +02:00
parent 59c6b9d15e
commit 50cfc74ed0
2 changed files with 45 additions and 32 deletions

View File

@ -100,3 +100,19 @@ The styles to choose from:
- post: the full path will be displayed after target, leaving all original text - post: the full path will be displayed after target, leaving all original text
At first it seems that `pre` and `post` are advantageous over `at` and `at-full`, since you can still see the original text with them. However, they make the text shift a bit. If you don't like that, use either `at` or `at-full`. At first it seems that `pre` and `post` are advantageous over `at` and `at-full`, since you can still see the original text with them. However, they make the text shift a bit. If you don't like that, use either `at` or `at-full`.
## Contributing
### Copyright Assignment
Avy is subject to the same [copyright assignment](http://www.gnu.org/prep/maintain/html_node/Copyright-Papers.html) policy as Emacs itself, org-mode, CEDET and other packages in [GNU ELPA](http://elpa.gnu.org/packages/). Any [legally significant](http://www.gnu.org/prep/maintain/html_node/Legally-Significant.html#Legally-Significant) contributions can only be accepted after the author has completed their paperwork. Please see [the request form](http://git.savannah.gnu.org/cgit/gnulib.git/tree/doc/Copyright/request-assign.future) if you want to proceed.
The copyright assignment isn't a big deal, it just says that the copyright for your submitted changes to Emacs belongs to the FSF. This assignment works for all projects related to Emacs. To obtain it, you need to send one email, then send one letter (if you live in the US, it's digital), and wait for some time (in my case, I had to wait for one month).
### Style
The basic code style guide is to use `(setq indent-tabs-mode nil)`. It is provided for you in [.dir-locals.el](https://github.com/abo-abo/avy/blob/master/.dir-locals.el), please obey it.
Before submitting the change, run `make compile` and `make test` to make sure that it doesn't introduce new compile warnings or test failures. Also run <kbd>M-x</kbd> `checkdoc` to see that your changes obey the documentation guidelines.
Use your own judgment for the commit messages, I recommend a verbose style using `magit-commit-add-log`.

61
avy.el
View File

@ -26,12 +26,12 @@
;;; Commentary: ;;; Commentary:
;; ;;
;; This package provides a generic completion method based on building ;; This package provides a generic completion method based on building
;; a balanced decision tree with each candidate being a leaf. To ;; a balanced decision tree with each candidate being a leaf. To
;; traverse the tree from the root to a desired leaf, typically a ;; traverse the tree from the root to a desired leaf, typically a
;; sequence of `read-char' can be used. ;; sequence of `read-char' can be used.
;; ;;
;; In order for `read-char' to make sense, the tree needs to be ;; In order for `read-char' to make sense, the tree needs to be
;; visualized appropriately, with a character at each branch node. So ;; visualized appropriately, with a character at each branch node. So
;; this completion method works only for things that you can see on ;; this completion method works only for things that you can see on
;; your screen, all at once: ;; your screen, all at once:
;; ;;
@ -516,31 +516,29 @@ STYLE determines the leading char overlay style."
;;* Commands ;;* Commands
;;;###autoload ;;;###autoload
(defun avy-goto-char (arg char) (defun avy-goto-char (char &optional arg)
"Read one char and jump to it. "Jump to the currently visible CHAR.
The window scope is determined by `avy-all-windows' (ARG negates it)." The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive (list current-prefix-arg (interactive (list (read-char "char: ")
(read-char "char: "))) current-prefix-arg))
(avy--with-avy-keys avy-goto-char (avy--with-avy-keys avy-goto-char
(avy--generic-jump (avy--generic-jump
(if (= 13 char) (if (= 13 char)
"\n" "\n"
(regexp-quote (string char))) (regexp-quote (string char)))
arg arg
avy-style))) avy-style)))
;;;###autoload ;;;###autoload
(defun avy-goto-char-2 (arg char1 char2) (defun avy-goto-char-2 (char1 char2 &optional arg)
"Read two consecutive chars and jump to the first one. "Jump to the currently visible CHAR1 followed by CHAR2.
The window scope is determined by `avy-all-windows' (ARG negates it)." The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive (list current-prefix-arg (interactive (list (read-char "char 1: ")
(read-char "char 1: ") (read-char "char 2: ")
(read-char "char 2: "))) current-prefix-arg))
(avy--with-avy-keys avy-goto-char-2 (avy--with-avy-keys avy-goto-char-2
(avy--generic-jump (avy--generic-jump
(regexp-quote (string (regexp-quote (string char1 char2))
char1
char2))
arg arg
avy-style))) avy-style)))
@ -566,11 +564,11 @@ The window scope is determined by `avy-all-windows' (ARG negates it)."
(avy--generic-jump "\\b\\sw" arg avy-style))) (avy--generic-jump "\\b\\sw" arg avy-style)))
;;;###autoload ;;;###autoload
(defun avy-goto-word-1 (arg char) (defun avy-goto-word-1 (char &optional arg)
"Read one char at word start and jump there. "Jump to the currently visible CHAR at a word start.
The window scope is determined by `avy-all-windows' (ARG negates it)." The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive (list current-prefix-arg (interactive (list (read-char "char: ")
(read-char "char: "))) current-prefix-arg))
(avy--with-avy-keys avy-goto-word-1 (avy--with-avy-keys avy-goto-word-1
(let* ((str (string char)) (let* ((str (string char))
(regex (cond ((string= str ".") (regex (cond ((string= str ".")
@ -615,25 +613,24 @@ should return true."
(avy--process candidates (avy--style-fn avy-style)))))) (avy--process candidates (avy--style-fn avy-style))))))
;;;###autoload ;;;###autoload
(defun avy-goto-subword-1 (arg char) (defun avy-goto-subword-1 (char arg)
"Prompt for a subword start char and jump there. "Jump to the currently visible CHAR at a subword start.
The window scope is determined by `avy-all-windows' (ARG negates it). The window scope is determined by `avy-all-windows' (ARG negates it).
The case is ignored." The case of CHAR is ignored."
(interactive (list current-prefix-arg (interactive (list (read-char "char: ")
(read-char "char: "))) current-prefix-arg))
(avy--with-avy-keys avy-goto-subword-1 (avy--with-avy-keys avy-goto-subword-1
(let ((char (downcase char))) (let ((char (downcase char)))
(avy-goto-subword-0 (avy-goto-subword-0
arg (lambda () (eq (downcase (char-after)) char)))))) arg (lambda () (eq (downcase (char-after)) char))))))
(defun avy-goto-word-or-subword-1 (&optional arg) (defun avy-goto-word-or-subword-1 ()
"Jump to a word or subword start, depending on `subword-mode'. "Forward to `avy-goto-subword-1' or `avy-goto-word-1'.
The window scope is determined by `avy-all-windows' (ARG negates it). Which one depends on variable `subword-mode'."
The case is ignored." (interactive)
(interactive "P")
(if (bound-and-true-p subword-mode) (if (bound-and-true-p subword-mode)
(avy-goto-subword-1 arg) (call-interactively #'avy-goto-subword-1)
(avy-goto-word-1 arg))) (call-interactively #'avy-goto-word-1)))
(defun avy--line (&optional arg) (defun avy--line (&optional arg)
"Select a line. "Select a line.