[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/thingatpt.el,v
From: |
Karl Fogel |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/thingatpt.el,v |
Date: |
Sat, 16 Jun 2007 01:03:38 +0000 |
CVSROOT: /cvsroot/emacs
Module name: emacs
Changes by: Karl Fogel <kfogel> 07/06/16 01:03:37
Index: thingatpt.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/thingatpt.el,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- thingatpt.el 21 Jan 2007 03:53:10 -0000 1.40
+++ thingatpt.el 16 Jun 2007 01:03:34 -0000 1.41
@@ -67,7 +67,7 @@
"Determine the start and end buffer locations for the THING at point.
THING is a symbol which specifies the kind of syntactic entity you want.
Possibilities include `symbol', `list', `sexp', `defun', `filename', `url',
-`word', `sentence', `whitespace', `line', `page' and others.
+`email', `word', `sentence', `whitespace', `line', `page' and others.
See the file `thingatpt.el' for documentation on how to define
a symbol as a valid THING.
@@ -124,7 +124,7 @@
"Return the THING at point.
THING is a symbol which specifies the kind of syntactic entity you want.
Possibilities include `symbol', `list', `sexp', `defun', `filename', `url',
-`word', `sentence', `whitespace', `line', `page' and others.
+`email', `word', `sentence', `whitespace', `line', `page' and others.
See the file `thingatpt.el' for documentation on how to define
a symbol as a valid THING."
@@ -340,6 +340,33 @@
(goto-char (car bounds))
(error "No URL here")))))
+;; Email addresses
+(defvar thing-at-point-email-regexp
+ "<?[-+_.~a-zA-Z][-+_.~:address@hidden>?"
+ "A regular expression probably matching an email address.
+This does not match the real name portion, only the address, optionally
+with angle brackets.")
+
+;; Haven't set 'forward-op on 'email nor defined 'forward-email' because
+;; not sure they're actually needed, and URL seems to skip them too.
+;; Note that (end-of-thing 'email) and (beginning-of-thing 'email)
+;; work automagically, though.
+
+(put 'email 'bounds-of-thing-at-point
+ (lambda ()
+ (let ((thing (thing-at-point-looking-at thing-at-point-email-regexp)))
+ (if thing
+ (let ((beginning (match-beginning 0))
+ (end (match-end 0)))
+ (cons beginning end))))))
+
+(put 'email 'thing-at-point
+ (lambda ()
+ (let ((boundary-pair (bounds-of-thing-at-point 'email)))
+ (if boundary-pair
+ (buffer-substring-no-properties
+ (car boundary-pair) (cdr boundary-pair))))))
+
;; Whitespace
(defun forward-whitespace (arg)
- [Emacs-diffs] Changes to emacs/lisp/thingatpt.el,v,
Karl Fogel <=