Re: [O] [PATCH] Small improvement of maintainability of link escaping

2013-11-17 Thread Michael Brand
On Sat, Oct 5, 2013 at 3:04 PM, Michael Brand
michael.ch.br...@gmail.com wrote:
 [...] related change that I will suggest with an ERT in a later
 patch: Just add + to org-link-escape-chars-browser.

For the records: This approach is wrong, for the better one see
http://lists.gnu.org/archive/html/emacs-orgmode/2013-11/msg00686.html

Michael



Re: [O] [PATCH] Small improvement of maintainability of link escaping

2013-10-17 Thread Carsten Dominik
Hi Michael,

applied, sorry for the delay, and thanks!

- Carsten

On 16.10.2013, at 15:49, Michael Brand michael.ch.br...@gmail.com wrote:

 Hi all
 
 On Sat, Oct 5, 2013 at 3:31 PM, Michael Brand
 michael.ch.br...@gmail.com wrote:
 Sorry, I attached the wrong patch (the other one that is waiting in
 another thread), here again.
 
 I would like to remind to review and apply the patch attached on
 [2013-10-05 Sat] to this thread
 (0001-Small-improvement-of-maintainability-of-link-escapin.patch.txt).
 
 Michael
 



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [O] [PATCH] Small improvement of maintainability of link escaping

2013-10-16 Thread Michael Brand
Hi all

On Sat, Oct 5, 2013 at 3:31 PM, Michael Brand
michael.ch.br...@gmail.com wrote:
 Sorry, I attached the wrong patch (the other one that is waiting in
 another thread), here again.

I would like to remind to review and apply the patch attached on
[2013-10-05 Sat] to this thread
(0001-Small-improvement-of-maintainability-of-link-escapin.patch.txt).

Michael



[O] [PATCH] Small improvement of maintainability of link escaping

2013-10-05 Thread Michael Brand
Hi all

I would like to ask to review and apply the attached patch. It is to
have a timely separatation from a related change that I will suggest
with an ERT in a later patch: Just add + to
org-link-escape-chars-browser.

Michael
From 119aad10f2144a1397f2b034bef46dc891dbae5a Mon Sep 17 00:00:00 2001
From: Michael Brand michael.ch.br...@gmail.com
Date: Mon, 30 Sep 2013 20:32:29 +0200
Subject: [PATCH] org-table-transpose-table-at-point: Preserve indentation and
 point

* lisp/org-table.el (org-table-transpose-table-at-point): Preserve
indentatinon of first row. Restore point to transposed field in
transposed table.
---
 lisp/org-table.el | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 5bc754c..7be77cc 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -1834,7 +1834,7 @@ blindly applies a recipe that works for simple tables.
  (goto-char beg)
 
 (defun org-table-transpose-table-at-point ()
-  Transpose orgmode table at point and eliminate hlines.
+  Transpose Org table at point and eliminate hlines.
 So a table like
 
 | 1 | 2 | 4 | 5 |
@@ -1849,9 +1849,11 @@ will be transposed as
 | 4 | c | g |
 | 5 | d | h |
 
-Note that horizontal lines disappeared.
+Note that horizontal lines disappear.
   (interactive)
   (let* ((table (delete 'hline (org-table-to-lisp)))
+(dline_old (org-table-current-line))
+(col_old (org-table-current-column))
 (contents (mapcar (lambda (p)
 (let ((tp table))
   (mapcar
@@ -1861,10 +1863,17 @@ Note that horizontal lines disappeared.
(setq tp (cdr tp
table)))
   (car table
-(delete-region (org-table-begin) (org-table-end))
-(insert (mapconcat (lambda(x) (concat |  (mapconcat 'identity x  |  ) 
  |\n ))
-   contents ))
-(org-table-align)))
+(goto-char (org-table-begin))
+(re-search-forward |)
+(backward-char)
+(delete-region (point) (org-table-end))
+(insert (mapconcat
+(lambda(x)
+  (concat |  (mapconcat 'identity x  |  )   |\n ))
+contents ))
+(org-table-goto-line col_old)
+(org-table-goto-column dline_old))
+  (org-table-align))
 
 ;;;###autoload
 (defun org-table-wrap-region (arg)
-- 
1.7.12.4 (Apple Git-37)



Re: [O] [PATCH] Small improvement of maintainability of link escaping

2013-10-05 Thread Michael Brand
Sorry, I attached the wrong patch (the other one that is waiting in
another thread), here again.
From 6d5f603058211ade3b5db118cb3a7d04fbf52a6e Mon Sep 17 00:00:00 2001
From: Michael Brand michael.ch.br...@gmail.com
Date: Sat, 5 Oct 2013 15:00:25 +0200
Subject: [PATCH] Small improvement of maintainability of link escaping

* lisp/org.el (org-link-escape-chars): Add comment with escape numbers
alphabetically ordered.
(org-link-escape-chars-browser): Add comment with escape numbers.
(org-link-escape): Use better readable char constant instead of number
constant for percent char.
(org-link-escape-browser): New function to substitute duplicate source
code.
(org-open-at-point): Substitute duplicate source code.
* testing/README: Make comment in source code example clearer.
* testing/lisp/test-org.el (test-org/org-link-escape-chars-browser):
Change URL to real use case and use the new function
`org-link-escape-browser'.
---
 lisp/org.el  | 32 ++--
 testing/README   |  4 ++--
 testing/lisp/test-org.el |  8 +---
 3 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 5ff9969..9149441 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9732,11 +9732,13 @@ according to FMT (default from 
`org-email-link-description-format').
  ]))
 
 (defconst org-link-escape-chars
-  '(?\ ?\[ ?\] ?\; ?\= ?\+)
+  ;;%20 %2B %3B %3D %5B %5D
+  '(?\  ?\+ ?\; ?\= ?\[ ?\])
   List of characters that should be escaped in link.
 This is the list that is used for internal purposes.)
 
 (defconst org-link-escape-chars-browser
+  ;;%20 %22
   '(?\  ?\)
   List of escapes for characters that are problematic in links.
 This is the list that is used before handing over to the browser.)
@@ -9758,7 +9760,7 @@ If optional argument MERGE is set, merge TABLE into
   (mapconcat
(lambda (char)
  (if (or (member char table)
-(and (or ( char 32) (= char 37) ( char 126))
+(and (or ( char 32) (= char ?\%) ( char 126))
  org-url-hexify-p))
 (mapconcat (lambda (sequence-element)
  (format %%%.2X sequence-element))
@@ -9767,6 +9769,13 @@ If optional argument MERGE is set, merge TABLE into
   (char-to-string char))) )
(char-to-string char))) text ))
 
+(defun org-link-escape-browser (text)
+  (if (org-string-match-p
+   (concat [[:nonascii:] org-link-escape-chars-browser ])
+   text)
+  (org-link-escape text org-link-escape-chars-browser)
+text))
+
 (defun org-link-unescape (str)
   Unhex hexified Unicode strings as returned from the JavaScript function
 encodeURIComponent.  E.g. `%C3%B6' is the german o-Umlaut.
@@ -10467,24 +10476,11 @@ application the system uses for this file type.
  (apply cmd (nreverse args1
 
   ((member type '(http https ftp news))
-   (browse-url
-(concat type :
-(if (org-string-match-p
- (concat [[:nonascii:]
- org-link-escape-chars-browser ])
- path)
-(org-link-escape path org-link-escape-chars-browser)
-  path
+   (browse-url (concat type : (org-link-escape-browser path
 
   ((string= type doi)
-   (browse-url
-(concat org-doi-server-url
-(if (org-string-match-p
- (concat [[:nonascii:]
- org-link-escape-chars-browser ])
- path)
-(org-link-escape path org-link-escape-chars-browser)
-  path
+   (browse-url (concat org-doi-server-url
+   (org-link-escape-browser path
 
   ((member type '(message))
(browse-url (concat type : path)))
diff --git a/testing/README b/testing/README
index 9601ea7..e25a109 100644
--- a/testing/README
+++ b/testing/README
@@ -64,9 +64,9 @@ load and run the test suite with the following commands.
Use this as a demo example of a failing test
#+BEGIN_SRC emacs-lisp
  (ert-deftest test-org/org-link-escape-ascii-character-demo-of-fail ()
-   (should (string= %5B  ;; expected is right
+   (should (string= %5B  ;; expecting %5B is right
 (org-link-escape [)))
-   (should (string= %5C  ;; expected is wrong, %5D would be right
+   (should (string= %5C  ;; expecting %5C is wrong, %5D right
 (org-link-escape ]
#+END_SRC
or evaluate the ert-deftest form of the test you want to run.  Then
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index b6c5558..32fa69e 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -524,9 +524,11 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/;
   Escape a URL to pass to `browse-url'.
   (should
(string=
-