[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a9d3d12 07/13: Added support for choosing which side of th
From: |
Ian Dunn |
Subject: |
[elpa] master a9d3d12 07/13: Added support for choosing which side of thing-at-point to consider for exclusion |
Date: |
Sun, 4 Feb 2018 12:32:34 -0500 (EST) |
branch: master
commit a9d3d125eaf0b9654a5653d3e91ffba8510962db
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>
Added support for choosing which side of thing-at-point to consider for
exclusion
* paced.el (paced-point-in-thing-at-point): New defcustom.
(paced-goto-beginning-of-thing-at-point):
(paced-goto-end-of-thing-at-point): New helper defuns.
(paced-excluded-p): Use them.
---
paced-tests.el | 14 ++++++++++++++
paced.el | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 60 insertions(+), 7 deletions(-)
diff --git a/paced-tests.el b/paced-tests.el
index 700af1c..d88bb4b 100644
--- a/paced-tests.el
+++ b/paced-tests.el
@@ -463,6 +463,20 @@
(should (equal (map-elt merged-2 'a) '("def")))
(should (equal (map-elt merged-2 'c) '("ghi")))))
+(ert-deftest paced-beginning-end-of-thing-at-point ()
+ "Test exclusion and `paced-point-in-thing-at-point-for-exclusion'."
+ (let* ((paced-exclude-function (lambda () (looking-at-p "one")))
+ (buffer-one (find-file-noselect paced-first-test-file)))
+ (with-current-buffer buffer-one
+ (goto-char (point-min))
+ (should (equal (paced-thing-at-point) "one"))
+ (let ((paced-point-in-thing-at-point-for-exclusion 'beginning))
+ (should (paced-excluded-p)))
+ (paced-forward-thing)
+ (should (equal (paced-thing-at-point) "one"))
+ (let ((paced-point-in-thing-at-point-for-exclusion 'end))
+ (should-not (paced-excluded-p))))))
+
(provide 'paced-tests)
;;; paced-tests.el ends here
diff --git a/paced.el b/paced.el
index 3f40176..337386a 100644
--- a/paced.el
+++ b/paced.el
@@ -118,6 +118,19 @@ allowing all files."
:group 'paced
:type 'boolean)
+(defcustom paced-point-in-thing-at-point-for-exclusion 'beginning
+ "Symbol to indicate from where exclusion should occur.
+
+If 'beginning, exclusion is checked at the beginning of the thing
+at point. If 'end, exclusion is checked at the end of the thing
+at point.
+
+See `paced-excluded-p' and `paced-exclude-function' for more
+information on exclusion."
+ :group 'paced
+ :type 'symbol
+ :options '(beginning end))
+
(defun paced--default-dictionary-sort-func (usage-hash)
@@ -460,7 +473,11 @@ since population mostly uses temporary buffers.")
"Local predicate to determine if thing at point should be excluded.
This should be a function of no arguments that returns non-nil if
-the current thing-at-point should be excluded from paced dictionaries.
+the current thing-at-point should be excluded from paced
+dictionaries. Exclusion is checked from the start or the end of
+the current thing, depending on `paced-point-in-thing-at-point-for-exclusion'.
+Point returns to its original position after the function is
+called.
By default, this allows everything.
@@ -472,12 +489,6 @@ A useful function for this is `paced-in-comment-p'.")
If POS is not specified, defaults to `point'."
(nth 8 (syntax-ppss (or pos (point)))))
-(defun paced-excluded-p ()
- "Return non-nil to exclude current thing at point.
-
-See `paced-exclude-function' for more."
- (funcall paced-exclude-function))
-
(defun paced-bounds-of-thing-at-point ()
"Get the bounds of the thing at point."
(bounds-of-thing-at-point paced-thing-at-point-constituent))
@@ -499,6 +510,34 @@ Things is based on `paced-thing-at-point-constituent'."
(interactive "p")
(forward-thing paced-thing-at-point-constituent number))
+(defun paced-goto-beginning-of-thing-at-point ()
+ "Move to the start of the current thing at point.
+
+Thing is based on `paced-thing-at-point-constituent'."
+ (goto-char (car (paced-bounds-of-thing-at-point))))
+
+(defun paced-goto-end-of-thing-at-point ()
+ "Move to the end of the current thing at point.
+
+Thing is based on `paced-thing-at-point-constituent'."
+ (goto-char (cdr (paced-bounds-of-thing-at-point))))
+
+(defun paced-excluded-p ()
+ "Return non-nil to exclude current thing at point.
+
+See `paced-exclude-function' for more.
+
+Exclusion can be performed from either the beginning or end of
+the thing at point. See `paced-point-in-thing-at-point-for-exclusion' for how
+to set this."
+ (save-excursion
+ (pcase paced-point-in-thing-at-point-for-exclusion
+ (`beginning
+ (paced-goto-beginning-of-thing-at-point))
+ (`end
+ (paced-goto-end-of-thing-at-point)))
+ (funcall paced-exclude-function)))
+
(defun paced-mixed-case-word-p (word)
"Return non-nil if WORD is mixed-case.
- [elpa] master updated (edbdf4e -> a9eb761), Ian Dunn, 2018/02/04
- [elpa] master 01069d1 02/13: Fixed failing effort test, Ian Dunn, 2018/02/04
- [elpa] master c7fc9a4 01/13: Updated copyright, Ian Dunn, 2018/02/04
- [elpa] master 13c02a6 06/13: Added dictionary printing, Ian Dunn, 2018/02/04
- [elpa] master a9d3d12 07/13: Added support for choosing which side of thing-at-point to consider for exclusion,
Ian Dunn <=
- [elpa] master 56eeaff 04/13: Fixed up Changelog in documentation, Ian Dunn, 2018/02/04
- [elpa] master b73fff8 09/13: Added paced-repopulate-current-dictionary-async, Ian Dunn, 2018/02/04
- [elpa] master 1171a76 08/13: Added support for excluding words past a certain character limit, Ian Dunn, 2018/02/04
- [elpa] master bc5d7cd 10/13: Silenced byte-compiler, Ian Dunn, 2018/02/04
- [elpa] master d57675f 03/13: Added new forms for set-property! and fixed up build system, Ian Dunn, 2018/02/04
- [elpa] master 35acd8c 05/13: Cleaned up Changelog some more, Ian Dunn, 2018/02/04
- [elpa] master a9eb761 13/13: Merge commit '35acd8c2f9710e54ec3f433ae4af40cfff635295', Ian Dunn, 2018/02/04
- [elpa] master 463d752 11/13: Cleaned up code and added documentation of new features, Ian Dunn, 2018/02/04
- [elpa] master f4d03a3 12/13: Merge commit '463d752d4703af93ea86df8f07b244e8fc851617', Ian Dunn, 2018/02/04