emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: emacs-orgmode@gnu.org
Subject: Re: from dired to an org file with list of files with links
Date: Fri, 11 Dec 2020 00:04:17 +0300	[thread overview]
Message-ID: <X9KNUccKUNiqgCJt@protected.rcdrun.com> (raw)
In-Reply-To: <877dpp78fy.fsf@mat.ucm.es>

Dear Uwe,

* Uwe Brauer <oub@mat.ucm.es> [2020-12-10 22:45]:
> 
> Hi 
> 
> Suppose via dired I see
> 
>   -rw-rw-r--   1 oub oub 1003 dic 10 18:17 auto-org-md-autoloads.el
>   -rw-rw-r--   1 oub oub 2,0K dic 10 18:17 auto-org-md.el
>   -rw-rw-r--   1 oub oub 2,3K dic 10 18:17 auto-org-md.elc
>   -rw-rw-r--   1 oub oub  486 dic 10 18:17 auto-org-md-pkg.el
> 
> I'd like to create a org file
> with lists these files and there links to it
> 
> Like this
> 
> 
> [[file:.emacs.d/elpa/auto-org-md-20180213.2343/auto-org-md-autoloads.el][outo-org-md-autoloads.el]]
> [[file:.emacs.d/elpa/auto-org-md-20180213.2343/auto-org-md.el][outo-org-md.el]]
> [[file:.emacs.d/elpa/auto-org-md-20180213.2343/auto-org-md.el][outo-org-md.el]]
> [[file:.emacs.d/elpa/auto-org-md-20180213.2343/auto-org-md.elc][outo-org-md.elc]]
> [[file:.emacs.d/elpa/auto-org-md-20180213.2343/auto-org-md-pkg.elc][outo-org-md-pkg.elc]]
> 
> Anybody know whether such a functionality/package exist?

(require 'dired-x)

(defun dired-to-org-links ()
  "Generates Org links for Dired files and stores in memory. Yank
it in other buffer"
  (interactive)
  (let* ((files (dired-get-marked-files)))
    (when files
      (kill-new
       (with-temp-buffer
	 (dolist (file files)
	   (let* ((base (file-name-nondirectory file))
		  (link (format "[[file:%s][%s]]\n" file base)))
	     (insert link)))
	 (buffer-string))))))


  parent reply	other threads:[~2020-12-10 21:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 19:44 from dired to an org file with list of files with links Uwe Brauer
2020-12-10 20:36 ` [one pkf found] (was: from dired to an org file with list of files with links) Uwe Brauer
2020-12-10 21:04 ` Jean Louis [this message]
2020-12-11  8:09   ` from dired to an org file with list of files with links Uwe Brauer
2020-12-11 16:14     ` TRS-80
2020-12-13 15:46       ` Jean Louis

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=X9KNUccKUNiqgCJt@protected.rcdrun.com \
    --to=bugs@gnu.support \
    --cc=emacs-orgmode@gnu.org \
    /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).