[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a3a7eac 51/62: Added default dictionary settings for popul
From: |
Ian Dunn |
Subject: |
[elpa] master a3a7eac 51/62: Added default dictionary settings for population |
Date: |
Sat, 9 Dec 2017 14:34:05 -0500 (EST) |
branch: master
commit a3a7eacb3dd45e27afb486df72b9e0d5064e18f8
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>
Added default dictionary settings for population
* paced.el (paced-dictionary): Added `default-population-properties' slot.
(paced-merge-properties): New defun.
(paced-dictionary-prepare-properties): New defmethod.
(paced-population-command-populate-dictionary): Use it to form property
list.
---
paced-tests.el | 12 ++++++++++++
paced.el | 36 +++++++++++++++++++++++++++++++++++-
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/paced-tests.el b/paced-tests.el
index d9d63d3..bc38f79 100644
--- a/paced-tests.el
+++ b/paced-tests.el
@@ -451,6 +451,18 @@
(should (paced-dictionary-completions test-dict "one" 'lambda))
(should-not (paced-dictionary-completions test-dict "o" 'lambda))))
+(ert-deftest paced-merge-properties ()
+ (let* ((prop-list-1 '((a . "abc") (b . "xyz")))
+ (prop-list-2 '((a . "def") (c . "ghi")))
+ (prop-list-3 nil)
+ (merged-1 (paced-merge-properties prop-list-1 prop-list-2))
+ (merged-2 (paced-merge-properties prop-list-3 prop-list-2)))
+ (should (equal (map-elt merged-1 'a) '("def")))
+ (should (equal (map-elt merged-1 'b) '("xyz")))
+ (should (equal (map-elt merged-1 'c) '("ghi")))
+ (should (equal (map-elt merged-2 'a) '("def")))
+ (should (equal (map-elt merged-2 'c) '("ghi")))))
+
(provide 'paced-tests)
;;; paced-tests.el ends here
diff --git a/paced.el b/paced.el
index 20d6403..525a94c 100644
--- a/paced.el
+++ b/paced.el
@@ -185,6 +185,22 @@ It can be one of the following:
:initform nil
:type boolean
:documentation "Non-nil if this dictionary has been updated since
it was last saved.")
+ (default-population-properties
+ :initarg :default-population-properties
+ :initform nil
+ :type list
+ :label "Default Properties"
+ :custom (alist :tag "Properties" :key-type variable :value-type sexp)
+ :documentation "Default properties for population commands.
+
+Each element is of the form (VAR VALUE). Each VAR will be set to
+VALUE during population for this dictionary.
+
+Properties set in the individual population commands will
+override settings here.
+
+Some suggested variables for this are `paced-exclude-function'
+and `paced-thing-at-point-constituent'.")
(sort-method :initarg :sort-method
:initform 'paced--default-dictionary-sort-func
:type function
@@ -806,6 +822,24 @@ Each element is of the form (VAR VALUE).
Some suggested variables for this are `paced-exclude-function'
and `paced-thing-at-point-constituent'.")))
+(defun paced-merge-properties (&rest props)
+ "Merge the properties in PROPS to a single form understood by `let'.
+
+PROPS is a list of alists, each mapping a variable to a value for
+that variable
+
+The maps in the end of PROPS take precedence over the beginning."
+ (let ((merged-map (apply 'map-merge 'list props)))
+ (map-apply (lambda (var val) (list var val)) merged-map)))
+
+(cl-defmethod paced-dictionary-prepare-properties ((dict paced-dictionary)
+ (cmd
paced-population-command))
+ "Merge the properties of DICT and CMD into a single form understood by `let'.
+
+Properties in CMD take precedence over those in DICT."
+ (paced-merge-properties (oref dict default-population-properties)
+ (oref cmd props)))
+
(cl-defmethod paced-population-command-prepare-props ((cmd
paced-population-command))
"Turn props of CMD into a form understood by `let'."
(with-slots (props) cmd
@@ -822,7 +856,7 @@ Return non-nil if setup was successful and population can
continue.")
"Populate DICT from CMD."
(let ((sources (paced-population-command-source-list cmd))
;; Turn props into a form understood by `let'.
- (props (paced-population-command-prepare-props cmd)))
+ (props (paced-dictionary-prepare-properties dict cmd)))
(dolist (source sources)
(with-temp-buffer
;; If pre is nil, continue.
- [elpa] master 5f9ddc6 35/62: Mention case handling in paced-dictionary-completions, (continued)
- [elpa] master 5f9ddc6 35/62: Mention case handling in paced-dictionary-completions, Ian Dunn, 2017/12/09
- [elpa] master 56129ca 27/62: Updated docstrings, Ian Dunn, 2017/12/09
- [elpa] master f0ac1d8 31/62: Added mixed-case case handling, Ian Dunn, 2017/12/09
- [elpa] master 5674746 49/62: Added function to check if point is in a comment, Ian Dunn, 2017/12/09
- [elpa] master 56944b8 44/62: Added documentation section for working with EDE, Ian Dunn, 2017/12/09
- [elpa] master 895f479 41/62: Pushed info pages, Ian Dunn, 2017/12/09
- [elpa] master 223809e 61/62: Fixed elpaignore file, Ian Dunn, 2017/12/09
- [elpa] master 2e306c8 40/62: Improved Introduction, Ian Dunn, 2017/12/09
- [elpa] master 139a199 53/62: Added note about dictionary properties, Ian Dunn, 2017/12/09
- [elpa] master 1234c0c 54/62: Updated info pages, Ian Dunn, 2017/12/09
- [elpa] master a3a7eac 51/62: Added default dictionary settings for population,
Ian Dunn <=
- [elpa] master 7535133 58/62: Updated copyright blocks in all files, Ian Dunn, 2017/12/09
- [elpa] master bfdb640 43/62: Updated pabbrev comparison, Ian Dunn, 2017/12/09
- [elpa] master 4823f53 55/62: Added section for a basic setup, Ian Dunn, 2017/12/09
- [elpa] master 69b0058 32/62: Remove test dependency on dictionary file, Ian Dunn, 2017/12/09
- [elpa] master 534df41 57/62: Updated info pages, Ian Dunn, 2017/12/09
- [elpa] master b7dc61d 59/62: Removed bootstrap.sh, Ian Dunn, 2017/12/09
- [elpa] master b07d853 60/62: Added elpaignore file, Ian Dunn, 2017/12/09
- [elpa] master 5480e97 52/62: Removed obsolete method, Ian Dunn, 2017/12/09
- [elpa] master bc054b8 46/62: Updated info pages, Ian Dunn, 2017/12/09
- [elpa] master 82bd0da 23/62: Fixed various defmethod names to use paced-dictionary- prefix, Ian Dunn, 2017/12/09