[O] Emulate a wiki a la wikidpad
Hey guys, I love orgmode and I've been using it for many years. I know there are wiki extensions for it and other extensions for emacs, but I've never found something as easy and straightforwards as WikiDPad. Wikidpad is a real-time wiki. It's really cool (http://wikidpad.sourceforge.net/). What I'm looking for is an extension that could automatically link camecased words in org files, and create its respective file in a specific directory, if the file does not exist. I know it wouldn't be too difficult to implement, but I'd like to check here first before trying to come up with a solution myself. The rationale is that it's a really great way to keep reference data, and since it's in real time, you don't need to export to a format like HTML to view it. It's just so convenient when brainstorming or for keeping notes. Cheers! Marcelo.
Re: [O] Emulate a wiki a la wikidpad
Marcelo de Moraes Serpa celose...@gmail.com writes: What I'm looking for is an extension that could automatically link camecased words in org files, and create its respective file in a specific directory, if the file does not exist. I know it wouldn't be too difficult to implement, but I'd like to check here first before trying to come up with a solution myself. org-wikinodes.el in the contrib/lisp directory? Charles -- Open Standards, Open Documents, and Open Source -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) signature.asc Description: PGP signature
Re: [O] Drag images from Firefox to org-mode
Hi Carsten, The dependencies are async, dnd and wget. In case dnd doesn't work, there's a fallback to clipboard via `current-kill'. I've just added a custom variable that takes either 'wget or 'curl as the download method. I tried before url-retrieve, but it was giving me some garbage in addition to the image. So unless I know reliably the format of the garbage I can't use url-retrieve. But if I figure it out, I could add url-retrieve as the third custom method. The updates are at https://github.com/abo-abo/org-download regards, Oleh On Thu, Oct 17, 2013 at 2:04 PM, Carsten Dominik drostekirs...@gmail.comwrote: Hi Oleh and others, does anyone know how general this code is? Does it works on different operating systems? We might want to include this into the Org core. - Carsten On Oct 16, 2013, at 12:04 PM, Oleh ohwoeo...@gmail.com wrote: Hi all, Here's a little hack that I use to make my life easier: (require 'async) (eval-when-compile (require 'cl)) (defun org-store-image (link basedir) (async-start `(lambda() (shell-command ,(format wget \%s\ -P \%s\ link (expand-file-name basedir (lexical-let ((cur-buf (current-buffer))) (lambda(x) (with-current-buffer cur-buf (org-display-inline-images)) (defun org-store-image-clipboard (link) Save image at address LINK to current directory's subdirectory DIR. DIR is the name of the current level 0 heading. (interactive (list (current-kill 0))) (let ((filename (car (last (split-string link / (dir (save-excursion (org-up-heading-all (1- (org-current-level))) (substring-no-properties (org-get-heading) (if (null (image-type-from-file-name filename)) (message not an image URL) (unless (file-exists-p (expand-file-name filename dir)) (org-store-image link dir)) (insert (format [[./%s/%s]] dir filename)) (org-display-inline-images (setcdr (assoc ^\\(https?\\|ftp\\|file\\|nfs\\):// dnd-protocol-alist) 'dnd-org-insert) (defun dnd-org-insert (uri action) (org-store-image-clipboard uri)) When it's a plain image, I can just drag it from the browser to org-mode. It will be downloaded in async to a subdirectory of the current directory and the link will be inserted at point. For stubborn images that are links I can right click to copy image location and call `org-store-image-clipboard' interactively. I hope it's useful to someone and that I'm not re-implementing standard functionality. regards, Oleh regards, Oleh
Re: [O] Drag images from Firefox to org-mode
Hi Oleh, this is very nice thank you. If you want, turn this into a patch to org.el. If not, I will do so later. - Carsten On Oct 18, 2013, at 11:24 AM, Oleh ohwoeo...@gmail.com wrote: Hi Carsten, The dependencies are async, dnd and wget. In case dnd doesn't work, there's a fallback to clipboard via `current-kill'. I've just added a custom variable that takes either 'wget or 'curl as the download method. I tried before url-retrieve, but it was giving me some garbage in addition to the image. So unless I know reliably the format of the garbage I can't use url-retrieve. But if I figure it out, I could add url-retrieve as the third custom method. The updates are at https://github.com/abo-abo/org-download regards, Oleh On Thu, Oct 17, 2013 at 2:04 PM, Carsten Dominik drostekirs...@gmail.com wrote: Hi Oleh and others, does anyone know how general this code is? Does it works on different operating systems? We might want to include this into the Org core. - Carsten On Oct 16, 2013, at 12:04 PM, Oleh ohwoeo...@gmail.com wrote: Hi all, Here's a little hack that I use to make my life easier: (require 'async) (eval-when-compile (require 'cl)) (defun org-store-image (link basedir) (async-start `(lambda() (shell-command ,(format wget \%s\ -P \%s\ link (expand-file-name basedir (lexical-let ((cur-buf (current-buffer))) (lambda(x) (with-current-buffer cur-buf (org-display-inline-images)) (defun org-store-image-clipboard (link) Save image at address LINK to current directory's subdirectory DIR. DIR is the name of the current level 0 heading. (interactive (list (current-kill 0))) (let ((filename (car (last (split-string link / (dir (save-excursion (org-up-heading-all (1- (org-current-level))) (substring-no-properties (org-get-heading) (if (null (image-type-from-file-name filename)) (message not an image URL) (unless (file-exists-p (expand-file-name filename dir)) (org-store-image link dir)) (insert (format [[./%s/%s]] dir filename)) (org-display-inline-images (setcdr (assoc ^\\(https?\\|ftp\\|file\\|nfs\\):// dnd-protocol-alist) 'dnd-org-insert) (defun dnd-org-insert (uri action) (org-store-image-clipboard uri)) When it's a plain image, I can just drag it from the browser to org-mode. It will be downloaded in async to a subdirectory of the current directory and the link will be inserted at point. For stubborn images that are links I can right click to copy image location and call `org-store-image-clipboard' interactively. I hope it's useful to someone and that I'm not re-implementing standard functionality. regards, Oleh regards, Oleh signature.asc Description: Message signed with OpenPGP using GPGMail
Re: [O] Drag images from Firefox to org-mode
Hi Carsten, You can commit it whenever you like. I don't currently have access to Windows or OSX, so it's hard to see if the code works everywhere. regards, Oleh On Fri, Oct 18, 2013 at 11:28 AM, Carsten Dominik drostekirs...@gmail.comwrote: Hi Oleh, this is very nice thank you. If you want, turn this into a patch to org.el. If not, I will do so later. - Carsten On Oct 18, 2013, at 11:24 AM, Oleh ohwoeo...@gmail.com wrote: Hi Carsten, The dependencies are async, dnd and wget. In case dnd doesn't work, there's a fallback to clipboard via `current-kill'. I've just added a custom variable that takes either 'wget or 'curl as the download method. I tried before url-retrieve, but it was giving me some garbage in addition to the image. So unless I know reliably the format of the garbage I can't use url-retrieve. But if I figure it out, I could add url-retrieve as the third custom method. The updates are at https://github.com/abo-abo/org-download regards, Oleh On Thu, Oct 17, 2013 at 2:04 PM, Carsten Dominik drostekirs...@gmail.com wrote: Hi Oleh and others, does anyone know how general this code is? Does it works on different operating systems? We might want to include this into the Org core. - Carsten On Oct 16, 2013, at 12:04 PM, Oleh ohwoeo...@gmail.com wrote: Hi all, Here's a little hack that I use to make my life easier: (require 'async) (eval-when-compile (require 'cl)) (defun org-store-image (link basedir) (async-start `(lambda() (shell-command ,(format wget \%s\ -P \%s\ link (expand-file-name basedir (lexical-let ((cur-buf (current-buffer))) (lambda(x) (with-current-buffer cur-buf (org-display-inline-images)) (defun org-store-image-clipboard (link) Save image at address LINK to current directory's subdirectory DIR. DIR is the name of the current level 0 heading. (interactive (list (current-kill 0))) (let ((filename (car (last (split-string link / (dir (save-excursion (org-up-heading-all (1- (org-current-level))) (substring-no-properties (org-get-heading) (if (null (image-type-from-file-name filename)) (message not an image URL) (unless (file-exists-p (expand-file-name filename dir)) (org-store-image link dir)) (insert (format [[./%s/%s]] dir filename)) (org-display-inline-images (setcdr (assoc ^\\(https?\\|ftp\\|file\\|nfs\\):// dnd-protocol-alist) 'dnd-org-insert) (defun dnd-org-insert (uri action) (org-store-image-clipboard uri)) When it's a plain image, I can just drag it from the browser to org-mode. It will be downloaded in async to a subdirectory of the current directory and the link will be inserted at point. For stubborn images that are links I can right click to copy image location and call `org-store-image-clipboard' interactively. I hope it's useful to someone and that I'm not re-implementing standard functionality. regards, Oleh regards, Oleh
Re: [O] Drag images from Firefox to org-mode
Oleh ohwoeo...@gmail.com writes: I tried before url-retrieve, but it was giving me some garbage in addition to the image. But if I figure it out, I could add url-retrieve as the third custom method. If the garbage is the HTTP headers, then that problem is solved in Rick Frankel's code. If there's any other garbage, perhaps you have a test case ? -- Nico.
Re: [O] Drag images from Firefox to org-mode
Hi Nicolas, I've just tested Rick Frankel's code, and I got a broken jpg (it's half green and distorted). It appears so it org-mode inline and in eog, but it displays properly in its own Emacs buffer. Looks like it needs more work. regards, Oleh On Fri, Oct 18, 2013 at 11:47 AM, Nicolas Richard theonewiththeevill...@yahoo.fr wrote: Oleh ohwoeo...@gmail.com writes: I tried before url-retrieve, but it was giving me some garbage in addition to the image. But if I figure it out, I could add url-retrieve as the third custom method. If the garbage is the HTTP headers, then that problem is solved in Rick Frankel's code. If there's any other garbage, perhaps you have a test case ? -- Nico.
Re: [O] Drag images from Firefox to org-mode
Le 18/10/2013 12:04, Oleh a écrit : I've just tested Rick Frankel's code, and I got a broken jpg (it's half green and distorted). It appears so it org-mode inline and in eog, but it displays properly in its own Emacs buffer. Looks like it needs more work. Could you please put the link and the file you get on the internet so they can be compared ? I have no such problems and just tried to use the code in a new 'url-retrieve method to your org-download.el : https://github.com/YoungFrog/org-download/tree/url-retrieve which worked fine for me (in fact, I have problems with the async package : the emacs process apparently doesn't stop ! but I don't think it's related to your code, I know I have problems with inferior processes...) -- Nico.
Re: [O] Drag images from Firefox to org-mode
Oleh ohwoeo...@gmail.com writes: I've just tested Rick Frankel's code, and I got a broken jpg (it's half green and distorted). It appears so it org-mode inline and in eog, but it displays properly in its own Emacs buffer. Looks like it needs more work. Perhaps you could test this version instead: ://github.com/YoungFrog/org-download/tree/url-retrieve-alt It uses write-region instead of write-file and binds coding-system-for-write to 'no-conversion -- Nico.
Re: [O] Drag images from Firefox to org-mode
[re-adding emacs-orgmode@gnu.org to cc, I don't know when it got lost] Le 18/10/2013 12:44, Oleh a écrit : I attach the downloaded google logo. Thanks. diffing them, it looks pretty much like an encoding problem. I just tried your code and it works fine for the same image. Did you try the url-retrieve or the url-retrieve-alt branch ? In the former case, I'm surprised : it should have a similar problem IIUC. -- Nico.
Re: [O] Drag images from Firefox to org-mode
Did you try the url-retrieve or the url-retrieve-alt branch ? The url-retrieve-alt branch. Oleh
[O] linebreak after tag of headline in ox-latex.el
Hello, I export frequently minutes with todos with latex to pdf. I always include planning information, e.g.: * NEXT Check this :Rasmus: DEADLINE: 2013-10-15 tis SCHEDULED: 2013-10-15 tis + some comments After upgrading to (Org-mode version 8.2.1, GNU Emacs 23.4.1 ) the deadline and schedule is not linebreaked after the tag. This gives a unwanted output with all task information on the same line. Without knowing if it is the most appropriate solution I propose adding \n in the last row of: (defun org-latex-format-headline-default-function (todo todo-type priority text tags) Default format function for a headline. See `org-latex-format-headline-function' for details. (concat (and todo (format {\\bfseries\\sffamily %s} todo)) (and priority (format \\framebox{\\#%c} priority)) text (and tags (format \\hfill{}\\textsc{%s}\n (mapconcat 'identity tags :) , in order to get a better output of the task todo. I tried the above and compiled and got the output as I wanted. However, I don’t know if there are any inconvenience by doing so. /rasmus rempling
Re: [O] [babel] Commenting out src blocks for tangling
Hello, Sorry to resurrect this old thread, but I cannot make this work. b...@altern.org writes: Rainer M Krug r.m.k...@gmail.com writes: I agree - COMMENTing a subtree should automatically disable tangling of code blocks in the subtree. Would this something which could be introduced easily, as it seems there are quite a few who assumed that it would be doing it? This is now the case in master: http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=8e0b45 I just tried it with my init file and it did not work. Here is a minimal example. Save this as test.org: --8---cut here---start-8--- * Testing #+BEGIN_SRC emacs-lisp (message hello world) #+END_SRC * COMMENT Commenting #+BEGIN_SRC emacs-lisp (message Salut le monde 2) #+END_SRC --8---cut here---end---8--- Then do a M-x org-babel-load-file giving test.org as file name. If you look at *Messages*, or at the generated test.el, you will see the second block has been tangled. Am I missing something with this feature, or is this a bug? (I tried with emacs -Q and loading a current org, and the same happens.) Thanks, Alan
Re: [O] Drag images from Firefox to org-mode
On 2013-10-18 01:29, Nicolas Richard wrote: Rick Frankel r...@rickster.com writes: One small problem, should be =(1+ (point))=, as the above leaves a blank newline at the head of the jpg, making it invalid. Oops, yes [Initially I had (search-forward \n\n), which worked fine,... then changed my mind and didn't test. Silly me.] Your code downloaded two images easily, but (signal :error (cdr err signals a weird error for me (something like: error in process filter: if: peculiar error: http, 404). I suggest: (error Error fetching URL %s: %s url (cdr err)) That seems fine. I was just following the suggestion in the doc string for `url-retrieve'. BTW, did you know that org already has a function which works perfectly for this purpose (well, it's synchronous, but otherwise...) `org-feed-get-feed'? It already has support for url-retrieve, curl and wget. Here's an implementation using it (which does not handle errors): #+BEGIN_SRC emacs-lisp (require 'org-feed) (defun fetch-image (url optional destdir) (with-current-buffer (org-feed-get-feed url) (write-file (expand-file-name (file-name-nondirectory url) destdir)) (when (display-graphic-p) (pop-to-buffer (current-buffer) #+END_SRC and the current implementation with a nicer error message: #+BEGIN_SRC emacs-lisp (defun fetch-image (url optional destdir) (url-retrieve url (lambda (status url destdir) (let ((err (plist-get status :error))) (if err (error \%s\ %s. url (downcase (nth 2 (assq (nth 2 err) url-http-codes)) (delete-region (point-min) (progn (re-search-forward ^$ nil 'move) (1+ (point (write-file (expand-file-name (file-name-nondirectory url) destdir)) (when (display-graphic-p) (pop-to-buffer (current-buffer `(,url ,destdir) nil t)) #+END_SRC both are fixed to only display the buffer if running under a window system (which can grok images.)
[O] [Babel] Exporting tangled file path
Hi all, Currently when I export a literate program I can see the chunks but not where they end up. It would be really useful if the chunks had a footnote or something that linked to the file where they were tangled. Is there a header argument that does that? Thanks! -deech
[O] Tracking office hours using Android, Memacs, and Org-mode
Hi! In case you are looking for a method to track the hours spent in the office (almost completely) automatically, you might want to take a look at the documentation I added today: https://github.com/novoid/Memacs/blob/master/docs/FAQs_and_Best_Practices.org#tracking-office-hours It's working fine for me and maybe it is of any help for others as well. -- mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode: get Memacs from https://github.com/novoid/Memacs https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github
Re: [O] Drag images from Firefox to org-mode
On 2013-10-18 07:00, Nicolas Richard wrote: [re-adding emacs-orgmode@gnu.org to cc, I don't know when it got lost] Le 18/10/2013 12:44, Oleh a écrit : I attach the downloaded google logo. I missed an email here... can you send me the url to the image you are having problems with? I just tried the google png on the home page (logo11w.png), and have no problems. Also, please try the updated version of fetch-image (in another thread, duplicated below). FYI, I am use Emacs. 24.3 with the included url.el. rick #+BEGIN_SRC emacs-lisp (defun fetch-image (url optional destdir) (url-retrieve url (lambda (status url destdir) (let ((err (plist-get status :error))) (if err (error \%s\ %s. url (downcase (nth 2 (assq (nth 2 err) url-http-codes)) (delete-region (point-min) (progn (re-search-forward ^$ nil 'move) (1+ (point (write-file (expand-file-name (file-name-nondirectory url) destdir)) (when (display-graphic-p) (pop-to-buffer (current-buffer `(,url ,destdir) nil t)) #+END_SRC
Re: [O] Drag images from Firefox to org-mode
Rick Frankel r...@rickster.com writes: Le 18/10/2013 12:44, Oleh a écrit : I attach the downloaded google logo. I missed an email here... can you send me the url to the image you are having problems with? I received it by email, here it is : http://cjoint.com/13oc/CJsrG1j2Szg.htm Note that using (let ((coding-system-for-write 'no-conversion)) (write-region nil nil filename nil nil nil 'confirm)) instead of (write-file ...) seemed to fix the problem for Oleh. -- Nico.
Re: [O] Drag images from Firefox to org-mode
Rick Frankel r...@rickster.com writes: On 2013-10-18 01:29, Nicolas Richard wrote: Rick Frankel r...@rickster.com writes: One small problem, should be =(1+ (point))=, as the above leaves a blank newline at the head of the jpg, making it invalid. Oops, yes [Initially I had (search-forward \n\n), which worked fine,... then changed my mind and didn't test. Silly me.] Your code downloaded two images easily, but (signal :error (cdr err signals a weird error for me (something like: error in process filter: if: peculiar error: http, 404). I suggest: (error Error fetching URL %s: %s url (cdr err)) That seems fine. I was just following the suggestion in the doc string for `url-retrieve'. Indeed, it is bizarre because err contains e.g. (error http 404), which is claimed to be of the form ERROR-SYMBOL . DATA, but (car DATA) must be a string according to (info (elisp) Signaling Errors) : , | For `error', the error message is | the CAR of DATA (that must be a string). ` BTW, did you know that org already has a function which works perfectly for this purpose (well, it's synchronous, but otherwise...) `org-feed-get-feed'? No, I didn't know that (but I think doing things asynchronously has added value). (let ((err (plist-get status :error))) (if err (error \%s\ %s. url (downcase (nth 2 (assq (nth 2 err) url-http-codes)) Nice -- Nico.
Re: [O] Drag images from Firefox to org-mode
On 2013-10-18 11:36, Nicolas Richard wrote: Note that using (let ((coding-system-for-write 'no-conversion)) (write-region nil nil filename nil nil nil 'confirm)) instead of (write-file ...) seemed to fix the problem for Oleh. got it. BTW, you might want to add the error message cleanup (i can't do a branch/pull request from where i am right now). Here's a diff: --- org-download.el 2013-10-18 11:40:21.879753800 -0400 +++ org-download.el.new 2013-10-18 11:41:45.742415000 -0400 @@ -108,7 +108,8 @@ Write current buffer to FILENAME and update inline images in BUFFER (let ((err (plist-get status :error))) (if err - (signal :error (cdr err + (error \%s\ %s. url + (downcase (nth 2 (assq (nth 2 err) url-http-codes)) (delete-region (point-min) (progn rick
Re: [O] [babel] Commenting out src blocks for tangling
Alan Schmitt alan.schm...@polytechnique.org writes: Hello, Sorry to resurrect this old thread, but I cannot make this work. b...@altern.org writes: Rainer M Krug r.m.k...@gmail.com writes: I agree - COMMENTing a subtree should automatically disable tangling of code blocks in the subtree. Would this something which could be introduced easily, as it seems there are quite a few who assumed that it would be doing it? This is now the case in master: http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=8e0b45 I just tried it with my init file and it did not work. Here is a minimal example. Save this as test.org: --8---cut here---start-8--- * Testing #+BEGIN_SRC emacs-lisp (message hello world) #+END_SRC * COMMENT Commenting #+BEGIN_SRC emacs-lisp (message Salut le monde 2) #+END_SRC --8---cut here---end---8--- Then do a M-x org-babel-load-file giving test.org as file name. If you look at *Messages*, or at the generated test.el, you will see the second block has been tangled. Am I missing something with this feature, or is this a bug? (I tried with emacs -Q and loading a current org, and the same happens.) I can't reproduce, both manual tangling and tangling through org-babel-load-file only tangle the first block for me. Maybe you aren't using a current version of Org-mode. I'm on. Org-mode version 8.2.1 (release_8.2.1-99-g2eef1b @ /home/eschulte/src/org-mode/lisp/) Cheers, Thanks, Alan -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
Re: [O] [Babel] Exporting tangled file path
aditya siram aditya.si...@gmail.com writes: Hi all, Currently when I export a literate program I can see the chunks but not where they end up. It would be really useful if the chunks had a footnote or something that linked to the file where they were tangled. Is there a header argument that does that? Thanks! -deech Try C-c C-v which runs the command org-babel-view-src-block-info on a code block. It will show you if the code block has a specified tangle name. If the value of tangle is yes then the name of the Org-mode file will be used. Best, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
Re: [O] [Babel] Exporting tangled file path
Thanks, but I was hoping there was some way of including that in the exported HTML/PDF etc. That way someone looking at the documentation can find their way back to the source file. As it stands (at least with the HTML exporter) there's no way to know where a chunk of code ends up. -deech On Fri, Oct 18, 2013 at 11:44 AM, Eric Schulte schulte.e...@gmail.comwrote: aditya siram aditya.si...@gmail.com writes: Hi all, Currently when I export a literate program I can see the chunks but not where they end up. It would be really useful if the chunks had a footnote or something that linked to the file where they were tangled. Is there a header argument that does that? Thanks! -deech Try C-c C-v which runs the command org-babel-view-src-block-info on a code block. It will show you if the code block has a specified tangle name. If the value of tangle is yes then the name of the Org-mode file will be used. Best, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
Re: [O] [Babel] Exporting tangled file path
Dnia 2013-10-18, o godz. 09:47:47 aditya siram aditya.si...@gmail.com napisał(a): Hi all, Currently when I export a literate program I can see the chunks but not where they end up. It would be really useful if the chunks had a footnote or something that linked to the file where they were tangled. Is there a header argument that does that? Thanks! -deech Would this help (in case of LaTeX, of course)? http://www.ctan.org/pkg/embedfile Hth, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Adam Mickiewicz University
Re: [O] [Babel] Exporting tangled file path
aditya siram aditya.si...@gmail.com writes: Thanks, but I was hoping there was some way of including that in the exported HTML/PDF etc. That way someone looking at the documentation can find their way back to the source file. As it stands (at least with the HTML exporter) there's no way to know where a chunk of code ends up. -deech This could be done using a custom export filter. See the manual and the org-export-filter-src-block-functions variable for more information. There was recently on discussion on how to add some very nice features to latex export using this hook. Best, On Fri, Oct 18, 2013 at 11:44 AM, Eric Schulte schulte.e...@gmail.comwrote: aditya siram aditya.si...@gmail.com writes: Hi all, Currently when I export a literate program I can see the chunks but not where they end up. It would be really useful if the chunks had a footnote or something that linked to the file where they were tangled. Is there a header argument that does that? Thanks! -deech Try C-c C-v which runs the command org-babel-view-src-block-info on a code block. It will show you if the code block has a specified tangle name. If the value of tangle is yes then the name of the Org-mode file will be used. Best, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D
Re: [O] Drag images from Firefox to org-mode
On 2013-10-18 11:36, Nicolas Richard wrote: Note that using (let ((coding-system-for-write 'no-conversion)) (write-region nil nil filename nil nil nil 'confirm)) instead of (write-file ...) seemed to fix the problem for Oleh. Attached is a patch against Nico's url-retrieve-alt which cleans-up some issues w/ the defcustoms and make the interactive version of `org-download-image' prompt for a url instead of attempting to use the clipboard (which kept throwing errors for me). At least in my environment (Chrome - cygwin emacs on Windows NT),DND doesn't work on windows. It also uses url-parse to get the image file name, as images with cache-busters were failing to download (e.g. http://example.com/image.jpg?20120101). Again, sorry I can't do a branch and pull request, don't have push access to github from here. rickFrom 818b6a661087bfabb7363e06249bb925740f9616 Mon Sep 17 00:00:00 2001 From: Rick Frankel r...@rickster.com Date: Fri, 18 Oct 2013 14:03:03 -0400 Subject: [PATCH] * org-download.el (): - org-download-image-dir: Fix mismatch error (string set to nil.) - org-download--backend-cmd: Removed. - org-download-backend: Use a choice instead of a string reprensenting the tag. (org-download--fullname): Use url-parse to remove query params urls. Use `file-name-nondirectory' instead of splitting on slashes. (org-download--image): Use `org-download-backend' directly and generate better error messages for `url-retrieve' failures. (org-download-image): Prompt for image url instead of attempting to use the clipboard directly. Fix docstring to better match implementation. --- org-download.el | 49 - 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/org-download.el b/org-download.el index e7ae1a1..1d9ca40 100644 --- a/org-download.el +++ b/org-download.el @@ -33,6 +33,7 @@ (eval-when-compile (require 'cl)) +(require 'url-parse) (defgroup org-download nil Image drag-and-drop for org-mode. @@ -40,24 +41,18 @@ :prefix org-download-) (defcustom org-download-image-dir nil - If not nil, `org-download-image' will store images here. - :type 'string + If set, images will be stored in this directory +instead of the default (see `org-download-image'.) + :type '(choice (const :tag Default nil) + (string :tag Directory)) :group 'org-download) -(defvar org-download--backend-cmd nil - Backend command for downloading. - -Do not set this directly. Customize `org-download-backend' instead.) - -(defcustom org-download-backend 'wget - Set this to `wget' or `curl' or `url-retrieve' - :set (lambda (symbol value) - (case value - (wget (setq org-download--backend-cmd wget \%s\ -O \%s\)) - (curl (setq org-download--backend-cmd curl \%s\ -o \%s\)) - (url-retrieve t) - (t (error Unsupported key: %s value))) - (set-default symbol value)) +(defcustom org-download-backend t + Method to use for downloading + :type '(choice + (const :tag wget wget \%s\ -O \%s\) + (const :tag curl curl \%s\ -o \%s\) + (const :tag url-retrieve t)) :group 'org-download) (defcustom org-download-timestamp _%Y-%m-%d_%H:%M:%S @@ -91,7 +86,10 @@ Set this to \\ if you don't want time stamps. It's affected by `org-download-timestamp' and `org-download-image-dir' custom variables. - (let ((filename (car (last (split-string link / + (let ((filename + (file-name-nondirectory + (car (url-path-and-query +(url-generic-parse-url link) (dir (org-download--dir))) (format %s/%s%s.%s dir @@ -101,14 +99,16 @@ custom variables. (defun org-download--image (link filename) Save LINK to FILENAME asynchronously and show inline images in current buffer. - (if (eq org-download-backend 'url-retrieve) + (if (eq org-download-backend t) (url-retrieve link (lambda (status filename buffer) - Write current buffer to FILENAME and update inline images in BUFFER + ;; Write current buffer to FILENAME + ;; and update inline images in BUFFER (let ((err (plist-get status :error))) - (if err - (signal :error (cdr err + (if err (error +\%s\ %s. url +(downcase (nth 2 (assq (nth 2 err) url-http-codes)) (delete-region (point-min) (progn @@ -125,16 +125,15 @@ custom variables. (require 'async) (async-start `(lambda() (shell-command - ,(format org-download--backend-cmd link filename))) + ,(format org-download--backend link filename))) (lexical-let ((cur-buf (current-buffer))) (lambda(x) (with-current-buffer cur-buf (org-display-inline-images))) (defun org-download-image (link) - Save image at address LINK to current directory's sub-directory DIR.
Re: [O] Help on spreadsheet/calc references and improvements
Hi all On Sun, Oct 6, 2013 at 7:03 PM, Michael Brand michael.ch.br...@gmail.com wrote: @maintainers: According to the below I tried to improve the Org manual with the attached patch, please review and apply. I would like to remind to review and apply the patch attached on [2013-10-06 Sun] to this thread (0001-Improve-manual-for-table-formulas.patch.txt). Michael
[O] Export org to dot for an organization chart?
Hi, I'd like to produce an organization chart using org. What I want to do is: - enter an organization role as a section heading - have the heading hierarchy map to the organization hierarchy - enter optional section properties to specify: - the name of the individual who might fill the role - color and line types for drawing the box for the role - a URL associated with the role - section text providing a brief description of the role - render this into some nice looking graphic The end result I'm going for is a clickable image on a web page made by rendering the organization chart such that clicking on a box sends the browser to the role-specific URL and the alt text for that link gives the section text. Is there already something along these lines? Some searches turned up empty My thinking is that if there was an org-export-as-dot then it would be close to what I want. I found org-export-as-freemind which is in the right direction but I think lacks some of what I want and I'd like to avoid using a GUI in the process. Thanks for any ideas on this. If there is nothing like this yet, maybe I can use it as an excuse to learn org's new export system. -Brett. PS: rough example org file might look like: * Boss :PROPERTIES: :Actor: Bob Bigbooty :URL: http://www.example.com/boss.html :NodeColor: blue :END: The boss dictates. ** Middle Manager :PROPERTIES: :Actor: :URL: http://www.example.com/layer.html :NodeColor: red :END: The middle manager spectates. *** Flunky :PROPERTIES: :Actor: Sam Small :URL: http://www.example.com/hardworker.html :END: While the flunky gets stuff done. pgpd7J_RKfACP.pgp Description: PGP signature
Re: [O] Drag images from Firefox to org-mode
Thanks, Rick and Nico, I've merged the code. All except the last bit from Rick: I can't think of any sensible way to enter an image URL except pasting it. And since link will be in the clipboard at some point, why not use it straight away without prompting. Maybe URL can be prompted for when called with a prefix arg, but I don't know how to do that yet. regards, Oleh On Fri, Oct 18, 2013 at 8:24 PM, Rick Frankel r...@rickster.com wrote: On 2013-10-18 11:36, Nicolas Richard wrote: Note that using (let ((coding-system-for-write 'no-conversion)) (write-region nil nil filename nil nil nil 'confirm)) instead of (write-file ...) seemed to fix the problem for Oleh. Attached is a patch against Nico's url-retrieve-alt which cleans-up some issues w/ the defcustoms and make the interactive version of `org-download-image' prompt for a url instead of attempting to use the clipboard (which kept throwing errors for me). At least in my environment (Chrome - cygwin emacs on Windows NT),DND doesn't work on windows. It also uses url-parse to get the image file name, as images with cache-busters were failing to download (e.g. http://example.com/image.jpg?**20120101http://example.com/image.jpg?20120101 ). Again, sorry I can't do a branch and pull request, don't have push access to github from here. rick
Re: [O] Drag images from Firefox to org-mode
On Fri, Oct 18, 2013 at 09:22:17PM +0200, Oleh wrote: Thanks, Rick and Nico, I've merged the code. All except the last bit from Rick: I can't think of any sensible way to enter an image URL except pasting it. And since link will be in the clipboard at some point, why not use it straight away without prompting. Maybe URL can be prompted for when called with a prefix arg, but I don't know how to do that yet. I strongly disagree, for a couple of reasons: - Esp. on non-unix systems, the contents of the cut-buffer are not necessarily the same as the contents of the system clipboard. This is the problem I was having w/ your code on windows, where the cut-buffer contained the value of the current (or possibly last) selection, but the clipboard had a url. - It is certainly possible to type in a url - You might want to DND a url from another buffer. - It is ergonomically wrong for an interactive function defined to take an argument (and called download-image) to automagically use a value from somewhere else and not actually take an argument. It would however, make sense for the function to use the current clipboard contents if called with a prefix. In the same vein, I was thinking about the automagically creating a subdirectory based on a top level heading. This is also wrong for a couple reasons: - Creating a potentially =very long directory name with spaces= can cause multiple problems, both on unix and esp. non-unix systems, where spaces may not be allowed in directory names, or there may be limits on filename/directory length. - The use of the top-level heading is arbitrary and may have nothing to do with the current context (for instance, i sometimes group together multiple documents to be output w/ export subtree in the same master document) The default should be to save it in the same directory as the document (which by the way, may not be in emacs's idea of the current directory). Also, the filename should not be expanded to an absolute path, which makes the document non-portable and will break publishing. If you want the ability to create arbitrary output directories based on document context, the customization can be made to accept a function (lambda) as a value, which could then return a directory prefix. While i realize the current implementation meets your needs, if the code is to be included in the org-mode distribution it should follow emacs and org conventions and not contains any suprises. I would be glad to make the above changes on tuesday when i get back to the office. Please send me (again) the url of the github repos with the current set of changes and I will update it so that it will allow the current functionality but have less magical default behavior. rick
[O] Create sub-directories and files from within org
If I create a project with ** project name, is there any way to create a sub-directory at *** level in ~/projects/project name and create txt files in that directory - all from within org? Thanks.