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

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

[elpa] externals/ebdb 7dd034d 349/350: Fix up record citation, bind a co


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb 7dd034d 349/350: Fix up record citation, bind a command in EBDB mode
Date: Mon, 14 Aug 2017 11:47:09 -0400 (EDT)

branch: externals/ebdb
commit 7dd034da6e26d1041d5a7fb9ec97f6322f057aeb
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Fix up record citation, bind a command in EBDB mode
    
    * ebdb-com.el (ebdb-cite-records-ebdb): New interactive command in
      ebdb-mode for copying record citations to the kill ring.
      (ebdb-mode-map): Bind.
    * ebdb.el (ebdb-cite-records): Accept a new INSERT argument, saying
      whether to insert the citation ring, or copy it to the kill ring.
      (ebdb-records-cite): Fix most of the methods. Can't use text-mode,
      since both html-mode and org-mode derive from that.
    * ebdb.org: Document command.
    * ebdb.texi: etc
    * ebdb.info: etc
---
 ebdb-com.el | 16 +++++++++++++
 ebdb.el     | 39 +++++++++++++++++++++++++------
 ebdb.info   | 77 ++++++++++++++++++++++++++++++++++---------------------------
 ebdb.org    |  7 ++++++
 ebdb.texi   | 12 ++++++++--
 5 files changed, 108 insertions(+), 43 deletions(-)

diff --git a/ebdb-com.el b/ebdb-com.el
index 7023c1d..97e0d07 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -261,6 +261,7 @@ display information."
     (define-key km (kbd "r")           'ebdb-reformat-records)
     (define-key km (kbd "f")           'ebdb-format-to-tmp-buffer)
     (define-key km (kbd "F")           'ebdb-format-all-records)
+    (define-key km (kbd "I")            'ebdb-cite-records-ebdb)
     (define-key km (kbd "C-k")         'ebdb-delete-field-or-record)
     (define-key km (kbd "i")           'ebdb-insert-field)
     (define-key km (kbd "s")           'ebdb-save)
@@ -2025,6 +2026,21 @@ for `ebdb-field-action'."
     (unless (string= "" to)
       (ebdb-compose-mail to subject))))
 
+;;; Citing
+
+(defun ebdb-cite-records-ebdb (arg records style)
+  (interactive
+   (list
+    current-prefix-arg
+    (ebdb-do-records)
+    (completing-read "Style: " '("org" "html" "message") nil t)))
+  (with-current-buffer (get-buffer-create "*EBDB Citation*")
+    (pcase style
+      ("org" (org-mode))
+      ("html" (html-mode))
+      (_ (message-mode)))
+    (ebdb-cite-records records arg)))
+
 ;;; completion
 
 ;;;###autoload
diff --git a/ebdb.el b/ebdb.el
index e30cb82..67ea7ca 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -4801,18 +4801,22 @@ The formatting rules are defined in 
`ebdb-address-format-list'."
 ;; "Citation" means inserting some sort of string representing the
 ;; record(s) into the current buffer.
 
-(defun ebdb-cite-records (&optional records arg)
+(defun ebdb-cite-records (&optional records arg insert)
   (interactive (list (ebdb-prompt-for-record)
                     current-prefix-arg))
   (let ((recs (if (listp records) records (list records)))
        (style (if arg 'list 'inline))
-       usable)
+       usable str)
     (dolist (r recs)
       (if-let ((m (ebdb-record-mail r t)))
          (push (cons r (or (object-assoc 'primary 'priority m)
                            (car m)))
                usable)))
-    (insert (ebdb-records-cite style usable))))
+    (setq str (ebdb-records-cite style usable))
+    (if insert
+       (insert str)
+      (kill-new str)
+      (message "Citation added to kill ring"))))
 
 (cl-defgeneric ebdb-records-cite (style records)
   "Insert mode-appropriate mail strings for RECORDS.
@@ -4823,8 +4827,9 @@ differently by different major modes.
 This is a generic function that dispatches on the value of
 `major-mode'.  It only inserts names and mail addresses.")
 
-(cl-defmethod ebdb-records-cite (_style records)
-  "The fallback catch-all method."
+(cl-defmethod ebdb-records-cite ((_style (eql inline))
+                                (records list)
+                                &context (major-mode message-mode))
   (when records
     (mapcar (lambda (pair)
              (format "%s <%s>"
@@ -4832,6 +4837,19 @@ This is a generic function that dispatches on the value 
of
                      (ebdb-string (cdr pair))))
            records)))
 
+(cl-defmethod ebdb-records-cite :around ((_style (eql inline))
+                                        (_records list)
+                                        &context (major-mode message-mode))
+  (let ((lst (cl-call-next-method)))
+    (mapconcat #'identity lst ", ")))
+
+
+(cl-defmethod ebdb-records-cite :around ((_style (eql list))
+                                        (_records list)
+                                        &context (major-mode message-mode))
+  (let ((lst (cl-call-next-method)))
+    (mapconcat #'identity lst "\n")))
+
 (cl-defmethod ebdb-records-cite :around ((_style (eql list))
                                         (_records list)
                                         &context (major-mode org-mode))
@@ -4840,8 +4858,14 @@ This is a generic function that dispatches on the value 
of
                 (format "- %s" elt))
               list "\n")))
 
+(cl-defmethod ebdb-records-cite :around ((_style (eql inline))
+                                        (_records list)
+                                        &context (major-mode org-mode))
+  (let ((lst (cl-call-next-method)))
+    (mapconcat #'identity list " ")))
+
 (cl-defmethod ebdb-records-cite
-    (_style (records list) &context (major-mode org-mode))
+  (_style (records list) &context (major-mode org-mode))
   "Insert RECORDS as a list of org links."
   (mapcar (lambda (pair)
            (format "[[mailto:%s][%s]]";
@@ -4858,7 +4882,8 @@ This is a generic function that dispatches on the value of
               list "\n")))
 
 (cl-defmethod ebdb-records-cite :around ((_style (eql inline))
-                                        (_records list))
+                                        (_records list)
+                                        &context (major-mode html-mode))
   (let ((list (cl-call-next-method)))
     (mapconcat #'identity list " ")))
 
diff --git a/ebdb.info b/ebdb.info
index 442c8af..e2fbf13 100644
--- a/ebdb.info
+++ b/ebdb.info
@@ -1014,6 +1014,13 @@ keybindings apply.
      Remove the record under point (or marked records) from the buffer
      (does not delete the records).
 
+‘I’     (‘ebdb-cite-records-ebdb’)
+
+     Put a “citation” for the record under point (or marked records)
+     onto the kill ring.  A “citation” is a name-and-mail string for the
+     record.  Prompt for a style, meaning a textual mode.  With a prefix
+     arg, arrange citations in a list, otherwise inline.
+
 ‘w f’     (‘ebdb-copy-fields-as-kill’)
 
      Copy the string value of the field under point to the kill ring.
@@ -1185,11 +1192,11 @@ dependencies may be installed from the package 
repositories.  Because
 function autoloading doesn’t work with generic methods, you’ll need to
 require the libraries in addition to simply installing them.
 
-   EBDB currently comes with only one country library, ‘ebdb-i18n-chn’,
-for Chinese-related fields.  It parses and displays phone numbers and
-names correctly, and also allows users to search on Chinese names using
-pinyin.  It can be installed from ELPA, and requires the ‘pyim’ package,
-available on MELPA.
+   There is currently only one country library written for EBDB,
+‘ebdb-i18n-chn’, for Chinese-related fields.  It parses and displays
+phone numbers and names correctly, and also allows users to search on
+Chinese names using pinyin.  It can be installed from ELPA, and requires
+the ‘pyim’ package, available on MELPA.
 
    The present dearth of libraries is a result of the author scratching
 his own itch.  Contributions of new libraries are very welcome (see
@@ -1822,14 +1829,16 @@ Index
                                                               (line   6)
 * Diary integration:                     Diary Integration.   (line   6)
 * ebdb-cite-records:                     Citing Records.      (line  11)
+* ebdb-cite-records-ebdb:                The Basics of ebdb-mode.
+                                                              (line  86)
 * ebdb-clone-buffer:                     EBDB Buffers.        (line  19)
 * ebdb-copy-fields-as-kill:              The Basics of ebdb-mode.
-                                                              (line  86)
+                                                              (line  93)
 * ebdb-copy-mail-as-kill:                The Basics of ebdb-mode.
-                                                              (line  95)
+                                                              (line 102)
 * ebdb-copy-record record to-db:         The EBDB Database.   (line  67)
 * ebdb-copy-records-as-kill:             The Basics of ebdb-mode.
-                                                              (line  90)
+                                                              (line  97)
 * ebdb-create-record:                    The Basics of ebdb-mode.
                                                               (line  25)
 * ebdb-create-record-extended:           The Basics of ebdb-mode.
@@ -1851,9 +1860,9 @@ Index
 * ebdb-format-to-tmp-buffer:             Exporting/Formatting.
                                                               (line  14)
 * ebdb-help:                             The Basics of ebdb-mode.
-                                                              (line 107)
+                                                              (line 114)
 * ebdb-info:                             The Basics of ebdb-mode.
-                                                              (line 111)
+                                                              (line 118)
 * ebdb-insert-field:                     The Basics of ebdb-mode.
                                                               (line  33)
 * ebdb-mail:                             The Basics of ebdb-mode.
@@ -1895,7 +1904,7 @@ Index
 * ebdb-reload-database db:               The EBDB Database.   (line  73)
 * ebdb-rename-buffer:                    EBDB Buffers.        (line  24)
 * ebdb-save:                             The Basics of ebdb-mode.
-                                                              (line 115)
+                                                              (line 122)
 * ebdb-search-invert:                    Searching.           (line  46)
 * ebdb-search-pop:                       Searching.           (line  53)
 * ebdb-snarf &optional string start end recs: Snarfing.       (line  15)
@@ -1910,9 +1919,9 @@ Index
 * Mail aliases:                          Mail Aliases.        (line   6)
 * Migrating from BBDB:                   Migration from BBDB. (line   6)
 * quit-window:                           The Basics of ebdb-mode.
-                                                              (line 119)
+                                                              (line 126)
 * revert-buffer:                         The Basics of ebdb-mode.
-                                                              (line 103)
+                                                              (line 110)
 * Searching the EBDB:                    Searching.           (line   6)
 * Snarfing text:                         Snarfing.            (line   6)
 
@@ -1948,27 +1957,27 @@ Node: EBDB Buffers26980
 Node: Searching28173
 Node: Changing Search Behavior29883
 Node: The Basics of ebdb-mode31133
-Node: Marking34497
-Node: Exporting/Formatting34925
-Node: Completion35884
-Node: Snarfing37095
-Node: Internationalization39074
-Node: Diary Integration41777
-Node: Mail Aliases42643
-Node: vCard Support43352
-Node: Org Integration43851
-Node: Citing Records45425
-Node: Hacking EBDB46184
-Node: Field Classes48514
-Node: Init and Delete Methods51451
-Node: The Labeled Field Class53007
-Node: Actions53843
-Node: Custom Field Searching54508
-Node: Formatting in the EBDB Buffer56296
-Node: Writing Internationalization Libraries58295
-Node: Writing Integration For New MUAs62646
-Node: Article snarfing66072
-Node: Index66794
+Node: Marking34822
+Node: Exporting/Formatting35250
+Node: Completion36209
+Node: Snarfing37420
+Node: Internationalization39399
+Node: Diary Integration42112
+Node: Mail Aliases42978
+Node: vCard Support43687
+Node: Org Integration44186
+Node: Citing Records45760
+Node: Hacking EBDB46519
+Node: Field Classes48849
+Node: Init and Delete Methods51786
+Node: The Labeled Field Class53342
+Node: Actions54178
+Node: Custom Field Searching54843
+Node: Formatting in the EBDB Buffer56631
+Node: Writing Internationalization Libraries58630
+Node: Writing Integration For New MUAs62981
+Node: Article snarfing66407
+Node: Index67129
 
 End Tag Table
 
diff --git a/ebdb.org b/ebdb.org
index 0ea98ad..d3fcb5c 100644
--- a/ebdb.org
+++ b/ebdb.org
@@ -719,6 +719,13 @@ keybindings apply.
   Remove the record under point (or marked records) from the buffer
   (does not delete the records).
 
+- Key: I, ebdb-cite-records-ebdb
+
+  Put a "citation" for the record under point (or marked records) onto
+  the kill ring.  A "citation" is a name-and-mail string for the
+  record.  Prompt for a style, meaning a textual mode.  With a prefix
+  arg, arrange citations in a list, otherwise inline.
+
 - Key: w f, ebdb-copy-fields-as-kill
 
   Copy the string value of the field under point to the kill ring.
diff --git a/ebdb.texi b/ebdb.texi
index ae13d0b..e8df91f 100644
--- a/ebdb.texi
+++ b/ebdb.texi
@@ -1102,6 +1102,15 @@ Redisplay the record under point.
 Remove the record under point (or marked records) from the buffer
 (does not delete the records).
 
address@hidden I
address@hidden ebdb-cite-records-ebdb
address@hidden @kbd{I} 
@address@hidden@address@hidden(@code{ebdb-cite-records-ebdb})
+
+Put a ``citation'' for the record under point (or marked records) onto
+the kill ring.  A ``citation'' is a name-and-mail string for the
+record.  Prompt for a style, meaning a textual mode.  With a prefix
+arg, arrange citations in a list, otherwise inline.
+
 @kindex w f
 @cindex ebdb-copy-fields-as-kill
 @item @kbd{w f} @address@hidden@address@hidden(@code{ebdb-copy-fields-as-kill})
@@ -1292,7 +1301,7 @@ dependencies may be installed from the package 
repositories.  Because
 function autoloading doesn't work with generic methods, you'll need to
 require the libraries in addition to simply installing them.
 
-EBDB currently comes with only one country library,
+There is currently only one country library written for EBDB,
 @file{ebdb-i18n-chn}, for Chinese-related
 fields.  It parses and displays phone numbers and names correctly, and
 also allows users to search on Chinese names using pinyin.  It can be
@@ -1319,7 +1328,6 @@ country code (international-aware).  EBDB will correctly 
display the
 country name for either type of storage, regardless of whether the
 internationalization library is loaded or not.
 
address@hidden ebdb-i18n-countries-pref-scripts
 @vindex ebdb-i18n-countries
 Country names are displayed in English by default, but users can alter
 the display of some country names if they choose.



reply via email to

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