From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daimrod Subject: Re: [PATCH] Add `org-reverse-string' Date: Sat, 26 Jan 2013 22:35:41 +0100 Message-ID: <87vcaj39w2.fsf@casa.home> References: <87zjzv3c92.fsf@casa.home> <8738xn3bfh.fsf@gmail.com> 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]:51374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzDNq-0005yr-Od for emacs-orgmode@gnu.org; Sat, 26 Jan 2013 16:33:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TzDNo-0004jy-1K for emacs-orgmode@gnu.org; Sat, 26 Jan 2013 16:33:54 -0500 Received: from mail-wg0-f46.google.com ([74.125.82.46]:52530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzDNn-0004jQ-N5 for emacs-orgmode@gnu.org; Sat, 26 Jan 2013 16:33:51 -0500 Received: by mail-wg0-f46.google.com with SMTP id fg15so935431wgb.25 for ; Sat, 26 Jan 2013 13:33:50 -0800 (PST) In-Reply-To: <8738xn3bfh.fsf@gmail.com> (Eric Schulte's message of "Sat, 26 Jan 2013 14:02:26 -0700") 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: Eric Schulte Cc: emacs-orgmode@gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Eric Schulte writes: > This patch looks fine to me, although you'll need to add a > `declare-function' call to the top of ob-core.el (and maybe to org-id as > well) or the compiler will complain. I've added a `declare-function' call to `ob-core.el' but I think I don't need to add it to `org-id.el' because it already require `org.el'. Thanks for taking time to review this patch. --=-=-= 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=2091c4d0fde589e23de3bebbc4d8f95f90e85dbc14 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Gr=3DC3=3DA9goire=3D20Jadi?=3D Date: Sat, 26 Jan 2013 22:27:51 +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(org-id-new, org-id-decode): Replace `org-id-reverse-string' by `org-reverse-string'. * lisp/ob-core.el(org-babel-trim): Replace `org-babel-reverse-string' by `org-reverse-string' and declare it. TINYCHANGE =2D-- lisp/ob-core.el | 9 +++------ lisp/org-id.el | 7 ++----- lisp/org.el | 4 ++++ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 9e4c8b1..7453955 100644 =2D-- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -91,6 +91,7 @@ (declare-function org-escape-code-in-region "org-src" (beg end)) (declare-function org-unescape-code-in-string "org-src" (s)) (declare-function org-table-to-lisp "org-table" (&optional txt)) +(declare-function org-reverse-string "org" (string)) =20 (defgroup org-babel nil "Code block evaluation and management in `org-mode' documents." @@ -2495,10 +2496,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 +2510,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) iQIcBAEBAgAGBQJRBEwuAAoJEBNzVHcrZRiURjQQAJ6ImhFvASrsaVHGXc7y7e/T V7G8ZrZE/1gAGYDI4lR76F0rLx62QDpPzieortWNzgsI1lCJcQX4ygSaAN3GxCzL gFuxFraPWqAcusYGz3GzDlgrPTqgPZjpWY+t0K2IZUo+c0TMmIAyfn6kXOIweIl1 LsDnLwKqXvf4gp1NxCpgrbe5BTH5x+o0RbfxYmu8v2U7LopKrJVJAtaWWYvbfTbD JvbMcROoXhAZqD9RDhRIPYf9fbzRXEqfKQngYDBJvRGwMCY5TpQliT/0y5IH9euB BkO8WtdXA+giMOQYs3fopslxH3I/BzL7YDFojewNzbqO+SIctnSXXpzguEKwiHyE rVwjF1f0sHTjYbE23gCX98gMLaqgG4zu+fHV4oO5l3TH/Z949aThIZ3DYUkcKpwH mecGqvPHjp0uNtXpzA2hNeJFu+cnW6rCeBkIzxpNJKQjkYYps1OVpVXQ2qZB111d eJVzdVnz7nbBi9uUCNcNd1ppFnqJHhs6aHIqX2zrq6HCQLH5LtkyHMqhefivWcn5 qPDdcxg2TPBDV7ZZHIJN8DpkQ9bNfOZ64zfdYrfbkWHUjN0YqJNFa2ufRfV5726y bOTl1kHAtqgT4/uWriMWud3Kt5e2D8ExvArY/1fs0sdOZhyV4gAsNj2fXWyOqNe6 U0eGxylMCiIcUodCqHXQ =w3Nk -----END PGP SIGNATURE----- --==-=-=--