From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 0CebCKMovF/bUAAA0tVLHw (envelope-from ) for ; Mon, 23 Nov 2020 21:24:51 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id AJp1BKMovF8QXgAAbx9fmQ (envelope-from ) for ; Mon, 23 Nov 2020 21:24:51 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 403E79404CA for ; Mon, 23 Nov 2020 21:24:50 +0000 (UTC) Received: from localhost ([::1]:33666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khJKJ-0004iQ-Nn for larch@yhetil.org; Mon, 23 Nov 2020 16:24:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khJ0u-0003nr-TC for emacs-orgmode@gnu.org; Mon, 23 Nov 2020 16:04:44 -0500 Received: from static.rcdrun.com ([95.85.24.50]:36269) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khJ0s-0007y8-FE for emacs-orgmode@gnu.org; Mon, 23 Nov 2020 16:04:44 -0500 Received: from localhost ([::ffff:41.202.241.56]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by static.rcdrun.com with ESMTPSA id 00000000002C0013.000000005FBC23E7.000015F6; Mon, 23 Nov 2020 21:04:39 +0000 Date: Tue, 24 Nov 2020 00:04:06 +0300 From: Jean Louis To: Diego Zamboni Subject: Re: Bring up a screen giving option to open a series of orgmode files Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0 (3d08634) (2020-11-07) Received-SPF: pass client-ip=95.85.24.50; envelope-from=bugs@gnu.support; helo=static.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerardo Moro , emacs-orgmode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.51 X-TUID: FFRkfE9XO5RV * Diego Zamboni [2020-11-23 12:53]: > Hi Gerardo, > > Apart from what others have suggested, what you can do if you have a fixed > list of files you want to quickly access, you could manually define > keybindings for them. I have four main files where I capture things, so I > define a submenu that allows me to access them quickly: > > (note: I got this idea originally from Sacha Chua's > https://sachachua.com/blog/2015/02/learn-take-notes-efficiently-org-mode/) > > First, I define a helper function to define keybindings that open files. > Note that this requires lexical binding to be enabled, so that the > =lambda= creates a closure, otherwise the keybindings don't work. > > #+begin_src emacs-lisp > (defun zz/add-file-keybinding (key file &optional desc) > (let ((key key) > (file file) > (desc desc)) > (map! :desc (or desc file) > key > (lambda () (interactive) (find-file file))))) > #+end_src > > (note #2: the map! macro is Doom Emacs-specific, should be replaced with > `bind-key` or equivalent if you are not using Doom) > > Now I define keybindings to access my commonly-used org files. > > #+begin_src emacs-lisp > (zz/add-file-keybinding "C-c z w" "~/Work/work.org.gpg" "work.org") > (zz/add-file-keybinding "C-c z i" "~/org/ideas.org" "ideas.org") > (zz/add-file-keybinding "C-c z p" "~/org/projects.org" "projects.org") > (zz/add-file-keybinding "C-c z d" "~/org/diary.org" "diary.org") > #+end_src Another idea how to quickly access those files could be with completion function which could also be bound to a key. (defun my-org-files () (interactive) (let* ((list '(("Work" . "~/Work/work.org.gpg") ("Ideas" . "~/org/ideas.org") ("Projects" . "~/org/projects.org") ("Diary" . "~/org/diary.org"))) (completion-ignore-case t) (file (completing-read "My files: " list)) (file (cdr (assoc file list)))) (find-file file))) or function that finds all org files and offers completion on such: (defun my-all-org-files () (interactive) (let* ((my-org-dir "~/Documents/Org") (all-org (directory-files my-org-dir t "\.org$")) (alist '()) (all-org-alist (dolist (org all-org alist) (setf (alist-get (file-name-base org) alist) org))) (completion-ignore-case t) (file (completing-read "My files: " all-org-alist)) (file (cdr (assoc file alist)))) (find-file file))) M-x my-all-org-files Even better is when you turn on some visual completion package such as M-x ivy-mode or M-x helm-mode package ivy is in GNU ELPA