From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#32372: [PATCH] Add "uuid" to thing-at-point.el Date: Sun, 05 Aug 2018 22:31:43 -0400 Message-ID: <8736vsz0mo.fsf@gmail.com> References: <87h8k88l47.fsf@konghq.com> <87effc8kj1.fsf@konghq.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1533522606 6298 195.159.176.226 (6 Aug 2018 02:30:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 6 Aug 2018 02:30:06 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 32372@debbugs.gnu.org To: Raimon Grau Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 06 04:30:01 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 1fmVHV-0001Wk-H8 for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Aug 2018 04:30:01 +0200 Original-Received: from localhost ([::1]:60384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmVJc-00071S-2J for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Aug 2018 22:32:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmVJV-00070A-Gc for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2018 22:32:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmVJS-0006XG-Dp for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2018 22:32:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37127) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmVJS-0006X7-9G for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2018 22:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fmVJR-0004uX-WA for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2018 22:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Aug 2018 02:32:01 +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.153352271318859 (code B ref 32372); Mon, 06 Aug 2018 02:32:01 +0000 Original-Received: (at 32372) by debbugs.gnu.org; 6 Aug 2018 02:31:53 +0000 Original-Received: from localhost ([127.0.0.1]:42145 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmVJJ-0004u1-II for submit@debbugs.gnu.org; Sun, 05 Aug 2018 22:31:53 -0400 Original-Received: from mail-it0-f68.google.com ([209.85.214.68]:55443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmVJG-0004te-Pf; Sun, 05 Aug 2018 22:31:51 -0400 Original-Received: by mail-it0-f68.google.com with SMTP id d10-v6so15468955itj.5; Sun, 05 Aug 2018 19:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=robbdieqbFWDQqedIfgrR1b26F+0RMv1m6w2SzM0BFw=; b=BpAOwid9S5efyfYPB7JCr4csUZFscWJPsQAQnINTnzWJ53130CJF8iafcyD+5RVaV9 BQnapQRE7bjnJhPsYyDsMK0L5N8e4F1C3x2HaEBu8UG1kOwnUnlju3xlhnLWE5A+HfZS TCZxjFDU/7WUsGOwuRzkOixmJ/c3a9fvzMPdHZbGuzAtHdGa6sWcY7lDoIyDu5vrXZuw AExl38Q+8IpIRsp5lFOZcP2tv16e8Yp/JvdVd7xgoSvUlPH4wBoUvssb9zIb18MMetLd ZgV6ZwfZgEtXHwhWuZCJmGH162ZsPbyxNqYXj0ATjaaDxrkFN5BEZIoNMkb63dVzHR5j gCLg== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=robbdieqbFWDQqedIfgrR1b26F+0RMv1m6w2SzM0BFw=; b=eAAO495jTl3KHNmRNZS+hGJ9XES7X4nmzKzDJxEn3n2FJmZ8fyDocvruZ1J9sZgAeR pVlip2LXdrp3xOr1InDFsk53u7J8IGbKHfJ70ULY/kck0tutYesFhDK3J/JDG9gpb6ya kPAZNmvhoTuIWTk2PLSav+FvwFtgqd2l0oKpiVB2Ni5Bko52UvqbmOMq/PC6X+O3b5Hb GKccrlRg8q4D3EO1ySEtFwnRRjRTPR8PE8ZGJS8GDp05X48xGLRdxHQ1WE0sDh0R11LD bmZ6HNTMTmNyMWVRJmF0o/2Q3tbY2G16A+PFCGroqjUI2WndPMg1BldjhJEIEVZHrORL pZ1A== X-Gm-Message-State: AOUpUlF8/BPFBHHQ1dJYUPbJTuXJzMQOtuSy6JSxR243xNiiZkdSSoOT 0wVksK8LEla6OhmmC04292RQj+GZ X-Google-Smtp-Source: AAOMgpeUlvzKoAshxdyDbka2yy/7gb5P2Pj1iBV1AVY9HKA1UtEQGe8wsFBFVfEIn+F0oXKZxLk8qQ== X-Received: by 2002:a24:94f:: with SMTP id 76-v6mr13443832itm.113.1533522705068; Sun, 05 Aug 2018 19:31:45 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id v82-v6sm4293848iod.14.2018.08.05.19.31.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Aug 2018 19:31:44 -0700 (PDT) In-Reply-To: <87effc8kj1.fsf@konghq.com> (Raimon Grau's message of "Mon, 06 Aug 2018 00:24:02 +0100") 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:149273 Archived-At: severity 32372 wishlist quit Raimon Grau writes: > Subject: [PATCH] Add uuid as allowed thingatpt symbol > > * lisp/thingatpt.el (thing-at-point-uuid-regexp): Add regexp for uuid. I guess you should mention something about the ops as well here. Though it's not 100% clear what kind of format you should use for those. Maybe just (top-level): Add 'bounds-of-thing-at-point' operation for 'uuid'. > +;; UUID > + > +(defvar thing-at-point-uuid-regexp > + (rx (and bow Using rx is okay, I think. There was some discussion about it on emacs-devel a little time ago, with most people saying the increased verbosity made them not want to use it, but I kind of like it myself. However, Stefan made the point that `and' is potentially a bit confusing, because it could be misread as intersection. It's better to use one of the synonyms `seq' or `:'. > + (or > + "00000000-0000-0000-0000-000000000000" > + (and > + (repeat 8 hex-digit) "-" > + (repeat 4 hex-digit) "-" > + (or "1" "2" "3" "4" "5") > + (repeat 3 hex-digit) "-" > + (or "8" "9" "a" "b" "A" "B") > + (repeat 3 hex-digit) "-" > + (repeat 12 hex-digit))) > + eow)) > + "A regular expression matching a UUID from versions 1 to 5. > + > + More info on uuid's format in > + https://tools.ietf.org/html/rfc4122." ) So, in that RFC I see this grammar UUID = time-low "-" time-mid "-" time-high-and-version "-" clock-seq-and-reserved clock-seq-low "-" node time-low = 4hexOctet time-mid = 2hexOctet time-high-and-version = 2hexOctet clock-seq-and-reserved = hexOctet clock-seq-low = hexOctet node = 6hexOctet hexOctet = hexDigit hexDigit hexDigit = "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / "a" / "b" / "c" / "d" / "e" / "f" / "A" / "B" / "C" / "D" / "E" / "F" It looks like you crafted a regexp which is a tighter match for just the UUID versions currently in use. I think we're better off with the looser definition though, that way it will continue to be correct even as new versions come out. Furthermore, I would guess a human user is going to be surprised if (thing-at-point 'uuid) picks up this 12345678-1234-1234-8123-123456789012 but not this: 12345678-1234-1234-5123-123456789012 > +(put 'uuid 'thing-at-point > + (lambda () > + (let ((boundary-pair (bounds-of-thing-at-point 'uuid))) > + (if boundary-pair > + (buffer-substring-no-properties > + (car boundary-pair) (cdr boundary-pair)))))) I think this isn't needed, because the `thing-at-point' function already does this for you: (let ((text (if (get thing 'thing-at-point) (funcall (get thing 'thing-at-point)) (let ((bounds (bounds-of-thing-at-point thing))) (when bounds (buffer-substring (car bounds) (cdr bounds)))))))