From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Raimon Grau Newsgroups: gmane.emacs.bugs Subject: bug#32372: [PATCH] Add "uuid" to thing-at-point.el Date: Tue, 07 Aug 2018 08:48:26 +0100 Message-ID: <87600m8vn9.fsf@konghq.com> References: <87h8k88l47.fsf@konghq.com> <87effc8kj1.fsf@konghq.com> <8736vsz0mo.fsf@gmail.com> <878t5j9674.fsf@konghq.com> <87mutzxq3k.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1533628173 19360 195.159.176.226 (7 Aug 2018 07:49:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 7 Aug 2018 07:49:33 +0000 (UTC) Cc: 32372@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 07 09:49:28 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmwkB-0004vB-PJ for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Aug 2018 09:49:28 +0200 Original-Received: from localhost ([::1]:37792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmwmI-0001F3-Hy for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Aug 2018 03:51:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmwlo-00013W-7k for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2018 03:51:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmwlj-0002Xj-8P for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2018 03:51:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38117) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmwlj-0002XY-0K for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2018 03:51:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fmwli-0002s0-Px for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2018 03:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Raimon Grau Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Aug 2018 07:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32372 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 32372-submit@debbugs.gnu.org id=B32372.153362821010937 (code B ref 32372); Tue, 07 Aug 2018 07:51:02 +0000 Original-Received: (at 32372) by debbugs.gnu.org; 7 Aug 2018 07:50:10 +0000 Original-Received: from localhost ([127.0.0.1]:43131 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmwkr-0002qK-Ff for submit@debbugs.gnu.org; Tue, 07 Aug 2018 03:50:09 -0400 Original-Received: from mail-wr1-f44.google.com ([209.85.221.44]:36990) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmwkp-0002pn-JN for 32372@debbugs.gnu.org; Tue, 07 Aug 2018 03:50:08 -0400 Original-Received: by mail-wr1-f44.google.com with SMTP id u12-v6so14765361wrr.4 for <32372@debbugs.gnu.org>; Tue, 07 Aug 2018 00:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konghq.com; s=google; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=8GibKOn12lOEIaR0/RdV1b/BJqTLtFg1G3/tUwqgTlk=; b=hnumJ9JNO/JXXbqmTE8O4GGZRHha24puuTATsMhT4TPq8wgCIT7jEZJotTL396Y5pA xqmKoG66oCxrrGYt4YUyYETX3FJAyd/rrbWeflMihxlxl0pq0gov5lltbMS1iss/GYcZ r8oHwYlNkGdpYPx9YamRL9YFS8eQqurghTw9s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=8GibKOn12lOEIaR0/RdV1b/BJqTLtFg1G3/tUwqgTlk=; b=Mw0gRrcCFieD+J4BHrdiK3+YsTman2XLbgdU8raJo/xXjpGdLk3VlkzVdijiL737EE f/PYlcHBIoCrPX2ufIEEtZ0LVyR0gd1E5GPnivsz+TurtxbnDIH0tiUSHE6vi0bqXWBU Ou8Jl9umlwAsGmO3WjL5GFwKK1hHUQIiY5DB+Htd9VDpYoS+50ScKkg/yNmYU2VOkCEa /uHyMGhfmAAhnrqF1Nz1DcJBEPqXAOQc2C6pKHSu2ENvgTBMzrXgmc93qEP+X7pP9/N/ rSr4TZxc5I9x+tFZ6EeEq7+R5CRaQUrfbMPELQ2bK7o2Cg4g2oJqqQ8EG41VHP3hJKxC OtNA== X-Gm-Message-State: AOUpUlFf92j76WU+Zoh/lWDWrMS8Z3fhbqYeC7xm/rf6W6t+uAW1w6a0 KRwdmVIgHiI7EFt2kFcuqaWsa07JLwg= X-Google-Smtp-Source: AA+uWPwVPnVAM0tW1WyD9nxzKEZjBHD4cVJ7zKFivbtRkkL731KA7fQTGI3Rq7qypUEpxb23WMxNYw== X-Received: by 2002:adf:9c93:: with SMTP id d19-v6mr489656wre.11.1533628201418; Tue, 07 Aug 2018 00:50:01 -0700 (PDT) Original-Received: from raikong (81.61.106.180.dyn.user.ono.com. [81.61.106.180]) by smtp.gmail.com with ESMTPSA id i14-v6sm1806512wmd.13.2018.08.07.00.49.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 00:50:00 -0700 (PDT) X-Google-Original-From: Raimon Grau In-Reply-To: <87mutzxq3k.fsf@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:149306 Archived-At: --=-=-= Content-Type: text/plain Noam Postavsky writes: > Raimon Grau writes: > >> +(put 'uuid 'bounds-of-thing-at-point >> + (lambda () >> + (let ((thing (thing-at-point-looking-at >> + thing-at-point-uuid-regexp 500))) > > I think since uuids are fixed size, we can just pass that length (36), > rather than the somewhat arbitrary 500. I adjusted it to 36 and removed the redundant `seq' on the rx expression. Attaching the updated patch. Thanks again for reviewing, Raimon Grau --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-uuid-as-allowed-thingatpt-symbol.patch >From 534c35917f17f3a73c780dcbcc4be86fafa97566 Mon Sep 17 00:00:00 2001 From: Raimon Grau Date: Sun, 5 Aug 2018 22:47:30 +0100 Subject: [PATCH] Add uuid as allowed thingatpt symbol * etc/NEWS: Mention changes in thingatpt.el. * lisp/thingatpt.el (thing-at-point-uuid-regexp): Add regexp for uuid. (top-level): Add 'bounds-of-thing-at-point' operation for 'uuid'. * test/lisp/thingatpt-tests.el: Add tests for uuid at point. --- etc/NEWS | 6 ++++++ lisp/thingatpt.el | 30 +++++++++++++++++++++++++++--- test/lisp/thingatpt-tests.el | 5 ++++- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index a1c12a6..ee94572 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -96,6 +96,12 @@ option 'vc-hg-symbolic-revision-styles' to the value '("{rev}")'. --- ** shadowfile.el has been rewritten to support Tramp file names. +--- +** thingatpt.el supports a new "thing" called 'uuid'. + +A symbol 'uuid' can be passed to thing-at-point and it returns the +uuid at point. + * New Modes and Packages in Emacs 26.2 diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 6a978fe..e0443f4 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -58,7 +58,7 @@ forward-thing "Move forward to the end of the Nth next THING. THING should be a symbol specifying a type of syntactic entity. Possibilities include `symbol', `list', `sexp', `defun', -`filename', `url', `email', `word', `sentence', `whitespace', +`filename', `url', `email', `uuid', `word', `sentence', `whitespace', `line', and `page'." (let ((forward-op (or (get thing 'forward-op) (intern-soft (format "forward-%s" thing))))) @@ -73,7 +73,7 @@ bounds-of-thing-at-point "Determine the start and end buffer locations for the THING at point. THING should be a symbol specifying a type of syntactic entity. Possibilities include `symbol', `list', `sexp', `defun', -`filename', `url', `email', `word', `sentence', `whitespace', +`filename', `url', `email', `uuid', `word', `sentence', `whitespace', `line', and `page'. See the file `thingatpt.el' for documentation on how to define a @@ -131,7 +131,7 @@ thing-at-point "Return the THING at point. THING should be a symbol specifying a type of syntactic entity. Possibilities include `symbol', `list', `sexp', `defun', -`filename', `url', `email', `word', `sentence', `whitespace', +`filename', `url', `email', `uuid', `word', `sentence', `whitespace', `line', `number', and `page'. When the optional argument NO-PROPERTIES is non-nil, @@ -554,6 +554,30 @@ thing-at-point-email-regexp (put 'buffer 'end-op (lambda () (goto-char (point-max)))) (put 'buffer 'beginning-op (lambda () (goto-char (point-min)))) +;; UUID + +(defvar thing-at-point-uuid-regexp + (rx bow + (repeat 8 hex-digit) "-" + (repeat 4 hex-digit) "-" + (repeat 4 hex-digit) "-" + (repeat 4 hex-digit) "-" + (repeat 12 hex-digit) + eow) + "A regular expression matching a UUID. + + More info on uuid's format in + https://tools.ietf.org/html/rfc4122." ) + +(put 'uuid 'bounds-of-thing-at-point + (lambda () + (let ((thing (thing-at-point-looking-at + thing-at-point-uuid-regexp 36))) + (if thing + (let ((beginning (match-beginning 0)) + (end (match-end 0))) + (cons beginning end)))))) + ;; Aliases (defun word-at-point () diff --git a/test/lisp/thingatpt-tests.el b/test/lisp/thingatpt-tests.el index cfb57de..b4a5fd9 100644 --- a/test/lisp/thingatpt-tests.el +++ b/test/lisp/thingatpt-tests.el @@ -65,7 +65,10 @@ thing-at-point-test-data ("http://example.com/ab)c" 4 url "http://example.com/ab)c") ;; URL markup, lacking schema ("" 1 url "mailto:foo@example.com") - ("" 1 url "ftp://ftp.example.net/abc/")) + ("" 1 url "ftp://ftp.example.net/abc/") + ;; UUID, only hex is allowed + ("01234567-89ab-cdef-ABCD-EF0123456789" 1 uuid "01234567-89ab-cdef-ABCD-EF0123456789") + ("01234567-89ab-cdef-ABCD-EF012345678G" 1 uuid nil)) "List of thing-at-point tests. Each list element should have the form -- 2.7.4 --=-=-=--