From a1d457133e8a01c2464887ce238c55b1b60d0c22 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Wed, 5 Nov 2008 23:43:04 +0100 Subject: [PATCH] Protect the attachment directory from getting a final newline. This is a first attempt to fix a strange bug reported by Bernt Hansen, where two attachment directories are created, one of them with a final newline. --- lisp/ChangeLog | 6 ++++++ lisp/org-attach.el | 6 +----- lisp/org-id.el | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 346da6fb4..0d91da92d 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,11 @@ 2008-11-05 Carsten Dominik + * org-attach.el (org-attach-dir): Remove duplicate ID creation + code. + + * org-id.el (org-id-new): Use `org-trim' to extract the uuid from + shell output. + * org.el (org-link-abbrev-alist): Improve customization type. * org-attach.el (org-attach-expand-link, org-attach-expand): New diff --git a/lisp/org-attach.el b/lisp/org-attach.el index b9993c435..9d04dd810 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -156,11 +156,7 @@ the directory and the corresponding ID will be created." (let ((uuid (org-id-get (point) create-if-not-exists-p))) (when (or uuid create-if-not-exists-p) (unless uuid - (let ((uuid-string (shell-command-to-string "uuidgen"))) - (setf uuid-string - (substring uuid-string 0 (1- (length uuid-string)))) - (org-entry-put (point) "ID" uuid-string) - (setf uuid uuid-string))) + (error "ID retrieval/creation failed")) (let ((attach-dir (expand-file-name (format "%s/%s" (substring uuid 0 2) diff --git a/lisp/org-id.el b/lisp/org-id.el index 5ba0c419a..d807c2bb4 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -251,7 +251,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"." (if (equal prefix ":") (setq prefix "")) (cond ((eq org-id-method 'uuidgen) - (setq unique (substring (shell-command-to-string "uuidgen") 1 -1))) + (setq unique (org-trim (shell-command-to-string "uuidgen")))) ((eq org-id-method 'org) (let* ((etime (org-id-reverse-string (org-id-time-to-b36))) (postfix (if org-id-include-domain