From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Karl Voit Newsgroups: gmane.emacs.help Subject: Elisp: help on string operations Date: Sat, 5 Nov 2016 20:17:56 +0100 Organization: www.karl-voit.at Message-ID: <2016-11-05T20-07-58@devnull.Karl-Voit.at> Reply-To: Karl Voit NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1478379493 31271 195.159.176.226 (5 Nov 2016 20:58:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 5 Nov 2016 20:58:13 +0000 (UTC) User-Agent: slrn/pre1.0.0-18 (Linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 05 21:58:09 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c382B-0005N6-Fg for geh-help-gnu-emacs@m.gmane.org; Sat, 05 Nov 2016 21:57:51 +0100 Original-Received: from localhost ([::1]:57682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c382E-0000xu-EG for geh-help-gnu-emacs@m.gmane.org; Sat, 05 Nov 2016 16:57:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c36UI-000879-Pk for help-gnu-emacs@gnu.org; Sat, 05 Nov 2016 15:18:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c36UE-0002bd-GO for help-gnu-emacs@gnu.org; Sat, 05 Nov 2016 15:18:46 -0400 Original-Received: from [195.159.176.226] (port=40255 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c36UE-0002ZZ-9y for help-gnu-emacs@gnu.org; Sat, 05 Nov 2016 15:18:42 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1c36U3-0007ut-9o for help-gnu-emacs@gnu.org; Sat, 05 Nov 2016 20:18:31 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 62 Original-X-Complaints-To: usenet@blaine.gmane.org X-GPG-Key: http://www.Karl-Voit.at/Karl_Voit_GnuPG_public_key.gpg X-Registered-Linux-User: 224337 X-Confession: Pastafarian http://www.venganza.org/ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-Mailman-Approved-At: Sat, 05 Nov 2016 16:57:28 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111680 Archived-At: 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