From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daimrod Subject: [PATCH] Add `org-reverse-string' Date: Sat, 26 Jan 2013 21:44:41 +0100 Message-ID: <87zjzv3c92.fsf@casa.home> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:37990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzCaf-0006Zq-In for emacs-orgmode@gnu.org; Sat, 26 Jan 2013 15:43:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TzCab-0004Du-AX for emacs-orgmode@gnu.org; Sat, 26 Jan 2013 15:43:05 -0500 Received: from we-in-x022c.1e100.net ([2a00:1450:400c:c03::22c]:64474 helo=mail-we0-x22c.google.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzCab-0004Dh-0x for emacs-orgmode@gnu.org; Sat, 26 Jan 2013 15:43:01 -0500 Received: by mail-we0-f172.google.com with SMTP id x10so781638wey.17 for ; Sat, 26 Jan 2013 12:43:00 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain I needed a `reverse-string' function and I've found two in Org Mode. `org-babel-reverse-string' and `org-id-reverse-string'. So instead of rolling my own (I'm playing with `org-contacts.el'), I think it would be better to unify those functions into one. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Unify-org-id-reverse-string-and-org-babel-reverse-st.patch Content-Transfer-Encoding: quoted-printable From=20e058c4fac767a5faffd8debaabc489c174eef583 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Gr=3DC3=3DA9goire=3D20Jadi?=3D Date: Sat, 26 Jan 2013 21:12:54 +0100 Subject: [PATCH] Unify `org-id-reverse-string' and `org-babel-reverse-strin= g' into `org-reverse-string' * lisp/org.el (org-reverse-string): Add `org-reverse-string' to reverse a string. * lisp/org-id.el: Replace `org-id-reverse-string' by `org-reverse-string'. * lisp/ob-core.el: Replace `org-babel-reverse-string' by `org-reverse-strin= g' TINYCHANGE =2D-- lisp/ob-core.el | 8 ++------ lisp/org-id.el | 7 ++----- lisp/org.el | 4 ++++ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 9e4c8b1..0a495d0 100644 =2D-- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -2495,10 +2495,6 @@ If the table is trivial, then return it as a scalar." (match-string 1 cell)) cell) t)) =20 =2D(defun org-babel-reverse-string (string) =2D "Return the reverse of STRING." =2D (apply 'string (reverse (string-to-list string)))) =2D (defun org-babel-chomp (string &optional regexp) "Strip trailing spaces and carriage returns from STRING. Default regexp used is \"[ \f\t\n\r\v]\" but can be @@ -2513,8 +2509,8 @@ overwritten by specifying a regexp as a second argume= nt." "Strip leading and trailing spaces and carriage returns from STRING. Like `org-babel-chomp' only it runs on both the front and back of the string." =2D (org-babel-chomp (org-babel-reverse-string =2D (org-babel-chomp (org-babel-reverse-string string) r= egexp)) + (org-babel-chomp (org-reverse-string + (org-babel-chomp (org-reverse-string string) regexp)) regexp)) =20 (defvar org-babel-org-babel-call-process-region-original nil) diff --git a/lisp/org-id.el b/lisp/org-id.el index b35ea5e..bb503bd 100644 =2D-- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -343,7 +343,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"." (unless (org-uuidgen-p unique) (setq unique (org-id-uuid)))) ((eq org-id-method 'org) =2D (let* ((etime (org-id-reverse-string (org-id-time-to-b36))) + (let* ((etime (org-reverse-string (org-id-time-to-b36))) (postfix (if org-id-include-domain (progn (require 'message) @@ -376,9 +376,6 @@ So a typical ID could look like \"Org:4nd91V40HI\"." (substring rnd 18 20) (substring rnd 20 32)))) =20 =2D(defun org-id-reverse-string (s) =2D (mapconcat 'char-to-string (nreverse (string-to-list s)) "")) =2D (defun org-id-int-to-b36-one-digit (i) "Turn an integer between 0 and 61 into a single character 0..9, A..Z, a.= .z." (cond @@ -432,7 +429,7 @@ and time is the usual three-integer representation of t= ime." (if (=3D 2 (length parts)) (setq prefix (car parts) time (nth 1 parts)) (setq prefix nil time (nth 0 parts))) =2D (setq time (org-id-reverse-string time)) + (setq time (org-reverse-string time)) (setq time (list (org-id-b36-to-int (substring time 0 4)) (org-id-b36-to-int (substring time 4 8)) (org-id-b36-to-int (substring time 8 12)))) diff --git a/lisp/org.el b/lisp/org.el index 5033cbf..65c8c60 100644 =2D-- a/lisp/org.el +++ b/lisp/org.el @@ -21038,6 +21038,10 @@ for the search purpose." (error "Unable to create a link to here")))) (org-occur-in-agenda-files (regexp-quote link)))) =20 +(defun org-reverse-string (string) + "Return the reverse of STRING." + (apply 'string (reverse (string-to-list string)))) + (defun org-uniquify (list) "Remove duplicate elements from LIST." (let (res) =2D-=20 1.7.10.4 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D-=20 Daimrod/Greg --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBAgAGBQJRBEA6AAoJEBNzVHcrZRiUQFYQAJpyTWvZze1ksN+j2Wgbi04/ t1/FdBJTcvQ5ZTvWPlMBdCcNpg9sCdjswvAjVCSwV5A2uzQft52om2WL/vQa9hTq 3Mg56AcKnjb9KfGlt1yhIfPKePtpJTvaRlxy6qSENJ5IZGj6JO1EOdVSnANn4sq9 /+zXz3v8pr627snOUNVpGceMsae1O7FwVhDdVFNjBmxjUXAf/9Knb23IdWXCvF8q jislIfov4kubcNNYk3WD3CUj5Eo+6K19ChT7yFnqBEGbIZZkTESZLyeCbNpT2Qmv AzyDSik7N8fEabdb1S6pQhSJwR/UafKDw0opkzTcx4iV+LL0BcDITGO7cOl95CUL cRvdvz4i+MfqgYOOzdPCAtNWvCy3ABT9cv1ZgzkEoHVi4cw7mtnTcvvZqCGGWSRL /S4zClLHU8n/i0zM2caigCqjTh86/1WHRW1iFcqIx25t9V0NnqX9MKgfgcBFG+Fo t9r8ydszbWh36+9wHGiK8gY8dO7WdeRN7jWiWFMu6LkMELHKm7VsiitLUAXcSHtG XzY+bQT5bk31eA/JE3Q/tbkHpvvjWFGJoOcJnriMbl2qasqFSHkeSxUZ1x/gBDiP aLhh0pK/v4+s39ml+gui04fbpR51Bd0+0tljU/7VEBIY7y8Pow0vp1FXq5xNJHQk 0NI6I2B3wA+a3Qkdfjkv =kPdL -----END PGP SIGNATURE----- --==-=-=--