[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 9a0cca1 321/350: Create ebdb-parse method for URL
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 9a0cca1 321/350: Create ebdb-parse method for URL fields |
Date: |
Mon, 14 Aug 2017 11:47:03 -0400 (EDT) |
branch: externals/ebdb
commit 9a0cca1a1bbafdbe712b28ec8442f54fdf508177
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Create ebdb-parse method for URL fields
* ebdb.el (ebdb-url-valid-schemes): First, a customization option for
valid URL schemes.
(ebdb-parse): Then a parse method. Check that the scheme is valid,
raise 'ebdb-unparseable otherwise.
---
ebdb.el | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/ebdb.el b/ebdb.el
index 3181591..78eb629 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -1717,6 +1717,16 @@ Eventually this method will go away."
;; URL field
+(defcustom ebdb-url-valid-schemes '("http:" "https:" "irc:")
+ "A list of strings matching schemes acceptable to
+ `ebdb-field-url' instances.
+
+Strings should not be regular expressions. They should include
+the colon character."
+
+ :group 'ebdb-record-edit
+ :type '(repeat string))
+
(defvar ebdb-url-label-list '("homepage")
"List of known URL labels.")
@@ -1739,6 +1749,18 @@ Eventually this method will go away."
(cl-defmethod ebdb-string ((field ebdb-field-url))
(slot-value field 'url))
+(cl-defmethod ebdb-parse ((class (subclass ebdb-field-url))
+ (str string)
+ &optional slots)
+ "Parse a URL.
+
+See `ebdb-url-valid-schemes' for a list of acceptable schemes."
+ (when (null (plist-get slots :url))
+ (if (string-match-p (regexp-opt ebdb-url-valid-schemes) str)
+ (setq slots (plist-put slots :url (string-trim str)))
+ (signal 'ebdb-unparseable (list "invalid URL scheme"))))
+ (cl-call-next-method class str slots))
+
;;; Fields that change EBDB's behavior.
;;; Mail aliases
- [elpa] externals/ebdb 0904c14 281/350: Split ebdb-org-open into two functions, (continued)
- [elpa] externals/ebdb 0904c14 281/350: Split ebdb-org-open into two functions, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 88fc231 280/350: ebdb-complete: Add mail-mode support (#44), Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 63d2588 285/350: Combine with previous commit, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5fd19ea 287/350: Simplify MUA record editing, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 8cdb1d1 307/350: Fix bug in ebdb-char-fold-search logic, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5329d89 306/350: Mark arg as used in call to ebdb-with-record-edits, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 56f8f5f 301/350: Mention Org integration in the manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c0910a1 312/350: Add test for multiple databases plus read only, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 9e5b55d 316/350: Set local variable correctly in manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e80675b 300/350: Mention support for completion frameworks in manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 9a0cca1 321/350: Create ebdb-parse method for URL fields,
Eric Abrahamsen <=
- [elpa] externals/ebdb b26e295 325/350: Fall back to human readable name of labeled fields, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 0fe0957 289/350: Large pile of manual, docstring, and comment edits, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4034f7a 331/350: Add phone field snarfing to the list of snarf routines, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 851c0f1 320/350: Half-implement signature snarfing for MUAs, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb d589a33 328/350: Internationalized ebdb-parse for phones wasn't doing enough setup, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4d26065 339/350: Prepare ebdb-gnorb to be extricated, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 27325c4 336/350: Replace trailing whitespace in tests, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb b990fdf 327/350: File header changes preparatory to breaking off separate libraries, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5f97295 337/350: Catching wrong error in internationalized version of name string, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 2c9d491 323/350: Rework snarf collection, Eric Abrahamsen, 2017/08/14