0

I have this line in my init.el:

(global-set-key (kbd "C-c g") (lambda() (interactive) (find-file "~/Dropbox/myorgfiles")))

So when I type C-c g I get the directory contents of the myorgfiles folder. But I would like to be able to start typing and get search results for that pattern within that myorgfiles folder. How could I manage to do this? At the moment the individual keyboard strokes have different functions.

  • So C-x C-f and start typing - what am I missing? – NickD Jul 5 at 17:45
  • I see that C-x C-f is binded to helm-find-files, and actually that is the function I could use. Instead, my function above calls find-file, and this function does not allow for start typing. I just fixed my above function like this: (global-set-key (kbd "C-c g") (lambda() (interactive) (helm-find-files "~/Dropbox/myorgfiles"))), and it WORKS! – Emmanuel Goldstein Jul 6 at 5:33
3

As @NickD said in a comment, what you want is just to call find-file interactively. But you want it to do its thing in folder ~/Dropbox/myorgfiles.

So you just need to bind default-directory to ~/Dropbox/myorgfiles/.

(global-set-key (kbd "C-c g")
                (lambda ()
                  (interactive)
                  (let ((default-directory  "~/Dropbox/myorgfiles/"))
                    (call-interactively #'find-file))))
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.