[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 1171a76 08/13: Added support for excluding words past a ce
From: |
Ian Dunn |
Subject: |
[elpa] master 1171a76 08/13: Added support for excluding words past a certain character limit |
Date: |
Sun, 4 Feb 2018 12:32:34 -0500 (EST) |
branch: master
commit 1171a763e515cd929a864f164734eb9104e4edab
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>
Added support for excluding words past a certain character limit
* paced.el (paced-character-limit): New defcustom.
(paced-length-of-thing-at-point):
(paced-thing-meets-limit-p): New helper defuns.
(paced-excluded-p): Use them.
* paced-tests.el (paced-character-limit): Test for new feature.
---
paced-tests.el | 14 ++++++++++++++
paced.el | 42 +++++++++++++++++++++++++++++++++---------
2 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/paced-tests.el b/paced-tests.el
index d88bb4b..e7b5552 100644
--- a/paced-tests.el
+++ b/paced-tests.el
@@ -477,6 +477,20 @@
(let ((paced-point-in-thing-at-point-for-exclusion 'end))
(should-not (paced-excluded-p))))))
+(ert-deftest paced-character-limit ()
+ "Test character limit."
+ (let* ((paced-exclude-function (lambda () nil))
+ (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-character-limit 0))
+ (should-not (paced-excluded-p)))
+ (let* ((paced-character-limit 1))
+ (should (paced-excluded-p)))
+ (let* ((paced-character-limit 3))
+ (should-not (paced-excluded-p))))))
+
(provide 'paced-tests)
;;; paced-tests.el ends here
diff --git a/paced.el b/paced.el
index 337386a..81bd748 100644
--- a/paced.el
+++ b/paced.el
@@ -131,6 +131,14 @@ information on exclusion."
:type 'symbol
:options '(beginning end))
+(defcustom paced-character-limit 0
+ "Character limit for including things in paced.
+
+If set to 0, impose no limit. Otherwise, include words whose
+length is less than or equal to the value."
+ :group 'paced
+ :type 'number)
+
(defun paced--default-dictionary-sort-func (usage-hash)
@@ -522,21 +530,37 @@ Thing is based on `paced-thing-at-point-constituent'."
Thing is based on `paced-thing-at-point-constituent'."
(goto-char (cdr (paced-bounds-of-thing-at-point))))
+(defun paced-length-of-thing-at-point ()
+ "Return the length, in characters, of the current thing at point."
+ (length (paced-thing-at-point)))
+
+(defun paced-thing-meets-limit-p ()
+ "Return non-nil if the current thing at point meets the limit requirement.
+
+The limit requirement is set with `paced-character-limit'."
+ (or (eq paced-character-limit 0)
+ (<= (paced-length-of-thing-at-point) paced-character-limit)))
+
(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)))
+the thing at point. See
+`paced-point-in-thing-at-point-for-exclusion' for how to set
+this.
+
+This also handles character limits set by
+`paced-character-limit'."
+ (or (not (paced-thing-meets-limit-p))
+ (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, 2018/02/04
- [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 <=
- [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