all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Karl Voit <devnull@Karl-Voit.at>
To: help-gnu-emacs@gnu.org
Subject: Elisp: help on string operations
Date: Sat, 5 Nov 2016 20:17:56 +0100	[thread overview]
Message-ID: <2016-11-05T20-07-58@devnull.Karl-Voit.at> (raw)

Hi!

For Memacs[1], I'd like to come up with a very fast Org-mode method to
open files independent of their location on your disk. I accomplished
everything necessary so far. However, I've got issues writing an elisp
function for extracting a file and sending it to a function that calls
the operating system app associated. My elisp knowledge is still too
bad :-(

What I've got is a string (from the lookup) which contains:
(1) nothing
(2) one line like "** <2008-06-17 21:43> [[file:/home/user/dir/2008-06-17 description of file.odp][2008-06-17 description of file.odp]]"
(3) multiple lines like (2) but with different files and links

I'd like to get a "Sorry" message for (1). Easy, if only I know how to
count lines in strings (as opposed to buffers).

For (2) I'd like to call my-open-in-external-app(string).

For (3), I'd like to use the first line just as in (2) as a starter. I
do have some ideas on gracious "error-recovering" on this one but
that's maybe too complicated to code for now: getting rid of
substrings delimited by not-'a-zA-Z0-9' from the end of the link
until a match is found; message in case there is no unique match which
could be found this way.

Could you please help me here?



The fragment I have so far is following but the regex seems to be
broken:

#+BEGIN_SRC elisp
    (let (
      (result (replace-regexp-in-string "\r?\n$" ""
                        (shell-command-to-string (concat "grep "
                                         "2008-06-17"
                                         " ~/org/memacs/files.org_archive")
                                     )
                        )
          )
      )
      (message (concat "result -> " result))
      (re-search-forward " \[\[.+\]\[" nil t 1)
      (let (
        (firstlink ((match-string 1)))
        )
        (message (concat "first link -> " firstlink))
       )
      )
#+END_SRC



[1] https://github.com/novoid/Memacs

-- 
All in all, one of the most disturbing things today is the definitive
fact that the NSA, GCHQ, and many more government organizations are
massively terrorizing the freedom of us and the next generations.
                                                  http://Karl-Voit.at




             reply	other threads:[~2016-11-05 19:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-05 19:17 Karl Voit [this message]
2016-11-08 14:16 ` Elisp: help on string operations Michael Heerdegen
2016-11-08 17:36   ` Karl Voit
2016-11-08 22:29     ` Michael Heerdegen

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

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

  git send-email \
    --in-reply-to=2016-11-05T20-07-58@devnull.Karl-Voit.at \
    --to=devnull@karl-voit.at \
    --cc=help-gnu-emacs@gnu.org \
    --cc=news1142@Karl-Voit.at \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.