Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deft always creates new files with .txt extension #49

Closed
olegbc1 opened this issue Feb 23, 2018 · 6 comments
Closed

Deft always creates new files with .txt extension #49

olegbc1 opened this issue Feb 23, 2018 · 6 comments

Comments

@olegbc1
Copy link

olegbc1 commented Feb 23, 2018

It appears that despite the configuration, deft always saves files with .txt extension.
Running Windows 10 and GNU Emacs 26.0.90 (build 3, x86_64-w64-mingw32) of 2017-10-13. Can you help me escape the corporate windows hell with emacs? :)

My config below

;; notational velocity like package https://jblevins.org/projects/deft/
  (use-package deft
  :straight t)

;; setting default extensions for deft to search
(setq deft-text-mode 'org-mode)
(setq deft-directory "~/Dropbox/Oleg/Org/")
(setq deft-new-file-format "%Y-%m-%dT%H%M") ;; on windows files with ":"-symbol can't be saved, so this is editing format to save in a format without ":"
(setq deft-extensions '("org"))
  
;; making deft also search for files in subdirectories
(setq deft-recursive t)

(global-set-key [C-f12] 'deft) 
@jrblevin
Copy link
Owner

Can you try configuring it like this and let me know if it works?

(use-package deft
  :bind ("C-<f12>" . deft)
  :init (setq deft-directory "~/Dropbox/Oleg/Org/"
              deft-text-mode 'org-mode
              deft-extensions '("org")
              deft-recursive t
              deft-new-file-format "%Y-%m-%dT%H%M"))

Otherwise, you can try setting deft-default-extension directly. It will default to the first value in deft-extensions, but for it to work that way the extensions list needs to be set before loading the package.

@olegbc1
Copy link
Author

olegbc1 commented Feb 26, 2018

@jrblevin your code worked - thanks! Do you know why this was better?

@jrblevin
Copy link
Owner

Glad it worked!

With use-package, :init evaluates the code before the package is loaded, so then when deft chooses the first element of deft-extensions, it's your custom list not the package default list (which begins with "txt").

@olegbc1
Copy link
Author

olegbc1 commented Feb 26, 2018

Thanks! Just to clarify - shouldn't (setq deft-extensions '("org")) declared after (use-package deft) just override the the package defaults?

@jrblevin
Copy link
Owner

The code in the package works like this:

(defcustom deft-extensions '("txt" "text" "md" "markdown" "org"))
(defvar deft-default-extension (car deft-extensions))

So, for better or worse, deft-default-extension is currently defined relative to the value of deft-extensions at package load time. Perhaps I should use a function instead, so that the default extensions can change dynamically.

@olegbc1
Copy link
Author

olegbc1 commented Feb 27, 2018

Got it, thanks! I'll flag this issue as closed.
Thanks for your work on these packages - deft, your themes and markdown mode are unbelievably useful!

@olegbc1 olegbc1 closed this as completed Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants