emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ido Magal <ido@idomagal.com>
To: Eric Schulte <schulte.eric@gmail.com>
Cc: emacs-orgmode@gnu.org, Rainer M Krug <r.m.krug@gmail.com>
Subject: Re: Embedded code
Date: Thu, 3 Feb 2011 22:52:27 -0800	[thread overview]
Message-ID: <AANLkTi=3ecxjEsP-PU+yBg7kvwKmyib6PAkf4Vph_znw@mail.gmail.com> (raw)
In-Reply-To: <87oc79elrj.fsf@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2521 bytes --]

On Fri, Jan 21, 2011 at 18:05, Eric Schulte <schulte.eric@gmail.com> wrote:
>
>
> There are a variety of ways to convert lists to strings, look at the
> `format' function for printing any elisp value to a string.  You can
> also use something like the following to convert a list to a string
>
> #+begin_src emacs-lisp
>  (mapconcat (lambda (el) (format "%S" el)) '(1 2 3 4 5 6) "\t")
> #+end_src
>
> ...

>
> You can use the inline code syntax for very small blocks, e.g.
>
>
I've proceeded with my little project using the dynamic block, since it
seems that this is what it was designed for. I wrote the following bit of
code and would appreciate answers to a couple of questions.

#+begin_src emacs-lisp :results silent
(defun flatten-string-with-links (str)
  (let* ((newstr str))
    ; find [[link][desc]] and replace with 'desc.
    (setq newstr (replace-regexp-in-string
"\\[\\[[^\\[]+\\]\\[[^//[]+\\]\\]"
                (lambda (s) (save-match-data
                         (nth 2 (split-string s "[\]\[]+")))) newstr))
    ; find [[link]] and replace with 'link.
    (setq newstr (replace-regexp-in-string "\\[\\[[^\\[]+\\]\\]"
    (lambda(s) (save-match-data
      (nth 1 (split-string s "[\]\[]+")))) newstr))
  newstr))

(defun org-dblock-write:tagged (params)
  (insert (mapconcat 'identity
     (org-map-entries
      (lambda()
 (let* (link desc innerlink)
  (setq desc (nth 4 (org-heading-components)))
  (setq desc (flatten-string-with-links desc))
  (setq link (concat "file:"
     (abbreviate-file-name (buffer-file-name (buffer-base-buffer)))
     "::"
     (org-make-org-heading-search-string)))
  (org-make-link-string link desc)))
 (plist-get params :tag)
(plist-get params :scope))
      "\n")))
 #+end_src

* example       :links:
** not a link
** [[http://google.com][link]]
** some text.[[http://google.com][link]]
** [[http://google.com]]
** some text. [[http://google.com][link]]. more text.
[[http://google.com][link]].
final text.
** [[
http://www.knifecenter.com/kc_new/store_detail.html?s%3DAOBSHARP][brokenlink]]

#+BEGIN: tagged :tag "links"
#+END


Q1: I've tried to leverage as much built-in org functionality as possible,
but deeply suspect that I'm overlooking some, since agendas do much of this
work.  Is there a simpler solution than mine?

Q2: The link generated for the last item ("broken link") does not work.
 Removing the "%" from the URL fixes it.  This seems to be a bug
in org-make-org-heading-search-string?  Or am I misusing it?

Any help would be greatly appreciated.

[-- Attachment #1.2: Type: text/html, Size: 5285 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  parent reply	other threads:[~2011-02-04  6:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-17 16:06 Embedded code Ido Magal
2011-01-17 22:01 ` Ido Magal
2011-01-17 23:48   ` Eric Schulte
2011-01-18  8:51     ` Rainer M Krug
2011-01-18 16:16       ` Eric Schulte
2011-01-18 16:44         ` Rainer M Krug
2011-01-18 17:12         ` Ido Magal
2011-01-18 18:35           ` Nick Dokos
2011-01-18 20:42           ` Eric Schulte
2011-01-19  6:46             ` Ido Magal
2011-01-21  3:54               ` Ido Magal
2011-01-22  2:05                 ` Eric Schulte
2011-01-22  2:10                   ` Ido Magal
2011-01-25  4:41                   ` Ido Magal
2011-01-25 17:16                     ` Eric Schulte
2011-01-26  4:44                       ` Ido Magal
2011-01-26  4:54                         ` Eric Schulte
2011-01-27 20:45                           ` Ido Magal
2011-01-26  9:41                         ` Sébastien Vauban
2011-01-27 22:51                           ` Eric Schulte
2011-02-04  6:52                   ` Ido Magal [this message]
2011-02-04 20:35                     ` Eric Schulte
2011-01-19 23:54         ` Dan Davison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTi=3ecxjEsP-PU+yBg7kvwKmyib6PAkf4Vph_znw@mail.gmail.com' \
    --to=ido@idomagal.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=r.m.krug@gmail.com \
    --cc=schulte.eric@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).