Code Monkey home page Code Monkey logo

deft's Introduction

Deft for Emacs MELPA badge MELPA stable badge Travis CI Build Status

Deft is an Emacs mode for quickly browsing, filtering, and editing directories of plain text notes, inspired by Notational Velocity. It was designed for increased productivity when writing and taking notes by making it fast and simple to find the right file at the right time and by automating many of the usual tasks such as creating new files and saving files.

Deft Screencast

Obtaining Deft

Deft is open source software and may be freely distributed and modified under the BSD license. The latest stable release is version 0.8, released on January 12, 2018.

Installation via MELPA Stable

The recommended way to install Deft is to obtain the stable version from MELPA Stable using package.el. First, configure package.el and the MELPA Stable repository by adding the following to your .emacs, init.el, or equivalent startup file:

(require 'package)
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/"))
(package-initialize)

Then, after restarting Emacs or evaluating the above statements, issue the following command: M-x package-install RET deft RET.

Direct Download

Alternatively you can manually download and install Deft. First, download the latest stable version of and save the file where Emacs can find it---a directory in your load-path:

Then, add the following line to your startup file:

(require 'deft)

Development Version

To follow or contribute to Deft development, you can browse or clone the Git repository on GitHub:

git clone https://github.com/jrblevin/deft.git

If you prefer to install and use the development version, which may become unstable at some times, you can either clone the Git repository as above or install Deft from MELPA.

If you clone the repository directly, then make sure that Emacs can find it by adding the following line to your startup file:

(add-to-list 'load-path "/path/to/deft/repository")

Overview

The Deft buffer is simply a file browser which lists the titles of all text files in the Deft directory followed by short summaries and last modified times. The title is taken to be the first line of the file and the summary is extracted from the text that follows. Files are, by default, sorted in terms of the last modified date, from newest to oldest.

All Deft files or notes are simple plain text files where the first line contains a title. As an example, the following directory structure generated the screenshot above.

% ls ~/.deft
about.txt    browser.txt     directory.txt   operations.txt
ack.txt      completion.txt  extensions.org
binding.txt  creation.txt    filtering.txt

% cat ~/.deft/about.txt
# About

An Emacs mode for slicing and dicing plain text files.

Deft's primary operation is searching and filtering. The list of files can be limited or filtered using a search string, which will match both the title and the body text. To initiate a filter, simply start typing. Filtering happens on the fly. As you type, the file browser is updated to include only files that match the current string.

To open the first matching file, simply press RET. If no files match your search string, pressing RET will create a new file using the string as the title. This is a very fast way to start writing new notes. The filename will be generated automatically. If you prefer to provide a specific filename, use C-RET instead.

To open files other than the first match, navigate up and down using C-p and C-n and press RET on the file you want to open. When opening a file, Deft searches forward and leaves the point at the end of the first match of the filter string.

You can also press C-o to open a file in another window, without switching to the other window. Issue the same command with a prefix argument, C-u C-o, to open the file in another window and switch to that window.

To edit the filter string, press DEL (backspace) to remove the last character or M-DEL to remove the last "word". To yank (paste) the most recently killed (cut or copied) text into the filter string, press C-y. Press C-c C-c to clear the filter string and display all files and C-c C-g to refresh the file browser using the current filter string.

For more advanced editing operations, you can also edit the filter string in the minibuffer by pressing C-c C-l. While in the minibuffer, the history of previous edits can be cycled through by pressing M-p and M-n. This form of static, one-time filtering (as opposed to incremental, on-the-fly filtering) may be preferable in some situations, such as over slow connections or on systems where interactive filtering performance is poor.

By default, Deft filters files in incremental string search mode, where "search string" will match all files containing both "search" and "string" in any order. Alternatively, Deft supports direct regexp filtering, where the filter string is interpreted as a formal regular expression. For example, ^\(foo\|bar\) matches foo or bar at the beginning of a line. Pressing C-c C-t will toggle between incremental and regexp search modes. Regexp search mode is indicated by an "R" in the mode line.

Common file operations can also be carried out from within Deft. Files can be renamed using C-c C-r or deleted using C-c C-d. New files can also be created using C-c C-n for quick creation or C-c C-m for a filename prompt; with a prefix argument, these operations ask for a file extension. You can leave Deft at any time with C-c C-q.

Unused files can be archived by pressing C-c C-a. Files will be moved to deft-archive-directory, which is a directory named archive within your deft-directory by default.

Files opened with deft are automatically saved after Emacs has been idle for a customizable number of seconds. This value is a floating point number given by deft-auto-save-interval (default: 1.0).

Getting Started

Once you have installed Deft following one of the above methods, you can simply run M-x deft to start Deft. It is useful to create a global keybinding for the deft function (e.g., a function key) to start it quickly (see below for details).

When you first run Deft, it will complain that it cannot find the ~/.deft directory. You can either create a symbolic link to another directory where you keep your notes or run M-x deft-setup to create the ~/.deft directory automatically.

One useful way to use Deft is to keep a directory of notes in a Dropbox folder. This can be used with other applications and mobile devices, for example, nvALT, Notational Velocity, or Simplenote on OS X or Editorial, Byword, or 1Writer on iOS.

Basic Customization

You can customize items in the deft group to change the default functionality.

By default, Deft looks for notes by searching for files with the extensions .txt, .text, .md, .markdown, or .org in the ~/.deft directory. You can customize both the file extension and the Deft directory by running M-x customize-group and typing deft. Alternatively, you can configure them in your .emacs file:

(setq deft-extensions '("txt" "tex" "org"))
(setq deft-directory "~/Dropbox/notes")

The first element of deft-extensions (or in Lisp parlance, the car) is the default extension used to create new files.

By default, Deft only searches for files in deft-directory but not in any subdirectories. All files in deft-directory with one of the specified extensions will be included except for those matching deft-ignore-file-regexp. Set deft-recursive to a non-nil value to enable searching for files in subdirectories (those not matching deft-recursive-ignore-dir-regexp):

(setq deft-recursive t)

You can easily set up a global keyboard binding for Deft. For example, to bind it to F8, add the following code to your .emacs file:

(global-set-key [f8] 'deft)

If you manage loading packages with use-package, then you can configure by adding a declaration such as this one to your init file:

(use-package deft
  :bind ("<f8>" . deft)
  :commands (deft)
  :config (setq deft-directory "~/Dropbox/notes"
                deft-extensions '("md" "org")))

Reading Files

The displayed title of each file is taken to be the first line of the file, with certain characters removed from the beginning. Hash characters, as used in Markdown headers, and asterisks, as in Org Mode headers, are removed. Additionally, Org mode #+TITLE: tags, MultiMarkdown Title: tags, LaTeX comment markers, and Emacs mode-line declarations (e.g., -*-mode-*-) are stripped from displayed titles. This can be customized by changing deft-strip-title-regexp.

More generally, the title post-processing function itself can be customized by setting deft-parse-title-function, which accepts the first line of the file as an argument and returns the parsed title to display in the file browser. The default function is deft-strip-title, which removes all occurrences of deft-strip-title-regexp as described above.

For compatibility with other applications which use the filename as the title of a note (rather than the first line of the file), set the deft-use-filename-as-title flag to a non-nil value. Deft will then use note filenames to generate the displayed titles in the Deft file browser. To enable this, add the following to your .emacs file:

(setq deft-use-filename-as-title t)

Finally, the short summary that is displayed following the file title can be customized by changing deft-strip-summary-regexp. By default, this is set to remove certain org-mode metadata statements such as #+OPTIONS: and #+AUTHOR:.

Creating Files

Filenames for newly created files are generated by Deft automatically. The process for doing so is determined by the variables deft-use-filename-as-title and deft-use-filter-string-for-filename as well as the rules in the deft-file-naming-rules alist. The possible cases are as follows:

  1. Default (deft-use-filename-as-title and deft-use-filter-string-for-filename are both nil):

    The filename will be automatically generated using an short, ISO-like timestamp as in 2016-05-12T09:00.txt. The format can be customized by setting the variable deft-new-file-format. The filter string will be inserted as the first line of the file (which is also used as the display title). In case of file name conflicts, an underscore and a numerical suffix (e.g., _2) will be appended before the extension.

  2. Filenames as titles (deft-use-filename-as-title is non-nil):

    When deft-use-filename-as-title is non-nil, the filter string will be used as the filename for new files (with the appropriate file extension appended to the end). An example of new file creation in this case:

    • Filter string: "My New Project"
    • File name: "My New Project.txt"
    • File contents: [empty]
  3. Readable filenames (deft-use-filename-as-title is nil but deft-use-filter-string-for-filename is non-nil):

    In this case you can choose to display the title as parsed from the first line of the file while also generating readable filenames for new files based on the filter string. The variable deft-use-filter-string-for-filename controls this behavior and decouples the title display (deft-use-filename-as-title) from the actual filename. New filenames will be generated from the filter string and processed according to the rules defined in the deft-file-naming-rules alist. By default, slashes are removed and replaced by hyphens, but many other options are possible (camel case, replacing spaces by hyphens, and so on). See the documentation for deft-file-naming-rules for additional details.

    As an example, with the following value for deft-file-naming-rules, Deft will replace all slashes and spaces with hyphens and will convert the file name to lowercase:

    (setq deft-file-naming-rules
          '((noslash . "-")
            (nospace . "-")
            (case-fn . downcase)))
    

    Below is an example in this case, with the above file naming rules. Notice that the filter string is inserted as the first line of the file but it is also used to generate a "readable" file name.

    • Filter string: "My New Project"
    • File name: "my-new-project.txt"
    • File contents: "My New Project"

Titles inserted into files from the filter string can also be customized for two common modes, markdown-mode and org-mode, by setting the following variables:

  • deft-markdown-mode-title-level - When set to a positive integer, determines how many hash marks will be added to titles in new Markdown files. In other words, setting deft-markdown-mode-title-level to 2 will result in new files being created with level-2 headings of the form ## Title.

  • deft-org-mode-title-prefix - When non-nil, automatically generated titles in new org-mode files will be prefixed with #+TITLE:.

Other Customizations

Deft, by default, lists files from newest to oldest. You can set deft-current-sort-method to 'title to sort by file titles, case ignored. Or, you can toggle sorting method using deft-toggle-sort-method.

Incremental string search is the default method of filtering on startup, but you can set deft-incremental-search to nil to make regexp search the default.

Deft also provides a function for opening files without using the Deft buffer directly. Calling deft-find-file will prompt for a file to open, much like find-file, but limits consideration to files in deft-directory that are known to Deft (i.e., those files matching deft-extensions). Unlike find-file, a list of all such files is provided and the desired file name can be completed using completing-read (and, as a result, deft-find-file will read/complete filenames using ido, helm, etc. when enabled). If the selected file is in deft-directory, it is opened with the usual Deft features (automatic saving, automatic updating of the Deft buffer, etc.). Otherwise, the file will be opened by find-file as usual. Therefore, you can set up a global keybinding for this function to open Deft files anywhere. For example, to use C-x C-g, a neighbor of C-x C-f, use the following:

(global-set-key (kbd "C-x C-g") 'deft-find-file)

The faces used for highlighting various parts of the screen can also be customized. By default, these faces inherit their properties from the standard font-lock faces defined by your current color theme.

Deft also provides several hooks: deft-mode-hook, deft-filter-hook, and deft-open-file-hook. See the documentation for these variables for further details.

Acknowledgments

Thanks to Konstantinos Efstathiou for writing simplenote.el, from which I borrowed liberally, and to Zachary Schneirov for writing Notational Velocity, whose functionality and spirit I wanted to bring to Emacs.

History

Version 0.8 (2018-01-12):

  • Limit deft-find-file to files known to Deft and support completing-read.
  • Keep subdirectory portion when displaying filenames.
  • New variable deft-width-offset for custom summary line width offset.
  • Attempt to restore point after refreshing browser and preserve position while filtering.
  • Add hooks: deft-filter-hook for filter string changes and deft-open-file-hook which runs after opening a file.
  • Prevent spurious Deft browser refreshes, which fixes an issue with sublimity-mode.
  • More reliable browser updates when window size changes.
  • Only update width when buffer is visible.
  • Lazily update the Deft buffer after saving files.
  • Close open buffer when deleting a file.
  • Initialize width even when started in background.
  • Omit files generated from org or markdown.
  • Custom format string deft-new-file-format for new file names.
  • Reduce summary line width when there is no fringe.
  • Support Org links.
  • Option deft-filter-only-filenames to filter only on file names.

Version 0.7 (2015-12-21):

  • Add custom regular expression deft-strip-summary-regexp for stripping extraneous text for generating the summary line. Strip all org-mode metadata by default.
  • New customizable regular expressions for ignoring files and directories. See deft-recursive-ignore-dir-regexp and deft-ignore-file-regexp.
  • Bug fix: Prevent lines from wrapping in console mode.
  • Bug fix: Setup deft-extensions and deft-default-extension at load time.
  • Bug fix: Try to prevent false title matches in org-mode notes where the string #+TITLE: might also appear in the body.
  • Bug fix: Use with-current-buffer instead of save-excursion while auto-saving files since we do not want to save the point.
  • Bug fix: Don't escape quotes in deft-file-naming-rules.

Version 0.6 (2015-06-26):

  • Recursive search in subdirectories (optional). Set deft-recursive to a non-nil value to enable.
  • Support for multiple extensions via the deft-extensions list. As such, deft-extension is now deprecated.
  • New variable deft-create-file-from-filter-string can enable generation of new filenames based on the filter string. This decouples the title display (deft-use-filename-as-title) from the actual filename generation.
  • New variable deft-file-naming-rules allows customizing generation of filenames with regard to letter case and handling of spaces.
  • New variables deft-markdown-mode-title-level and deft-org-mode-title-prefix for automatic insertion of title markup.
  • Archiving of files in deft-archive-directory.
  • Ability to sort by either title or modification time via deft-current-sort-method.
  • Update default deft-strip-title-regexp to remove the following:
    • org-mode #+TITLE: tags
    • MultiMarkdown Title: tags
    • LaTeX comment markers
    • Emacs mode-line declarations (e.g., -*-mode-*-)
  • Remove leading and trailing whitespace from titles.
  • Disable visual line mode to prevent lines from wrapping.
  • Enable line truncation to avoid displaying truncation characters.
  • Show the old filename as the default prompt when renaming a file.
  • Call hack-local-variables to read file-local variables when opening files.
  • Fixed several byte-compilation warnings.
  • Bug fix: more robust handling of relative and absolute filenames.
  • Bug fix: use width instead of length of strings for calculations.
  • Bug fix: fix string-width error with empty file.

Version 0.5.1 (2013-01-28):

  • Bug fix: creating files with C-c C-n when both the filter string and deft-use-filename-as-title are non-nil resulted in an invalid path.
  • Bug fix: killed buffers would persist in deft-auto-save-buffers.

Version 0.5 (2013-01-25):

  • Implement incremental string search (default) and regexp search. These search modes can be toggled by pressing C-c C-t.
  • Default search method can be changed by setting deft-incremental-search.
  • Support custom deft-parse-title-function for post-processing titles.
  • The default deft-parse-title-function simply strips occurrences of deft-strip-title-regexp, which removes Markdown and Org headings.
  • Open files in another window with C-o. Prefix it with C-u to switch to the other window.
  • For symbolic links, use modification time of taget for sorting.
  • When opening files, move point to the end of the first match of the filter string.
  • Improved filter editing: delete (DEL), delete word (M-DEL), and yank (C-y).
  • Advanced filter editing in minibuffer (C-c C-l).

Version 0.4 (2011-12-11):

  • Improved filtering performance.
  • Optionally take title from filename instead of first line of the contents (see deft-use-filename-as-title).
  • Dynamically resize width to fit the entire window.
  • Customizable time format (see deft-time-format).
  • Handle deft-directory properly with or without a trailing slash.

Version 0.3 (2011-09-11):

  • Internationalization: support filtering with multibyte characters.

Version 0.2 (2011-08-22):

  • Match filenames when filtering.
  • Automatically save opened files (optional).
  • Address some byte-compilation warnings.

Deft was originally written by Jason Blevins. The initial version, 0.1, was released on August 6, 2011.

deft's People

Contributors

brabalan avatar cmarcelo avatar cpin avatar credmp avatar djl avatar emreyolcu avatar glucas avatar iqbalansari avatar jonasagx avatar jrblevin avatar karvus avatar kaushalmodi avatar kjhealy avatar klazuka avatar kungsgeten avatar rahiel avatar raphaelfeng avatar robotdisco avatar shankar2k avatar timvisher avatar vivekhaldar avatar xrvdg avatar yannickmorin avatar yashi avatar yn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deft's Issues

possible to use call deft-open-file-in-other-window on file selection instead of the default?

I'd like for deft to open files in another window by default, instead of replacing the deft buffer. I didn't see immediately how this is possible reading the docs and issues. I'm not very good with elisp beyond editing config files and I'm about to dig into the deft code to see if I can figure this out, thought I'd ask on here as well.

Also, thank you so much for this app, I'm probably going to switch from Notational Velocity to deft in order to avoid switching out of spacemacs.

deft load errors when org not loaded

deft 0.7, emacs 24.5.1
I have org autoloaded, and when I launch deft before org, I get the following backtrace:

Debugger entered--Lisp error: (void-function org-add-link-type)
(org-add-link-type "deft" (function (lambda (handle) (org-open-file-with-emacs (expand-file-name handle deft-directory)))))
eval-buffer(#<buffer load> nil "/Users/dharms/.emacs.d/plugins/deft.el" nil t) ; Reading at buffer position 67056
load-with-code-conversion("/Users/dharms/.emacs.d/plugins/deft.el" "/Users/dharms/.emacs.d/plugins/deft.el" nil t)
autoload-do-load((autoload "deft" nil t nil) deft)
command-execute(deft)

change or disable auto-save interval

I've tried the following in my init.el to change or disable the auto-save interval without success:

(setq deft-auto-save-interval 5.0)

(setq deft-auto-save-interval nil)

I'm running deft 0.7 in spacemacs, if that matters.

Auto-refresh deft file list

Here is my deft config:

(global-set-key (kbd "<f8>") 'deft)
(setq deft-use-filename-as-title t)
(setq deft-use-filter-string-for-filename t)
(setq deft-directory "/Users/jaan/Library/Application\sSupport/Notational\sData")
(setq deft-extension "txt")
; associate files in deft directory with org mode
(add-to-list 'auto-mode-alist '("/Users/jaan/Library/Application\sSupport/Notational\sData/.*[.]txt$" . org-mode))

This lets deft sync with Simplenote (via Notational Velocity and the nvAlt app) so I can access my notes from multiple devices, but lets me use org-mode to take notes on my laptop.

However, if I create a file with Simplenote (in the directory above) existing Deft sessions will not update and new files do not show up.

I need to kill the buffer and reopen Deft to see the latest files in the Deft directory.

It would be nice if Deft sessions checked for changes to the file list every second or minute.

deft-open-file-hook is run outside of the context of the new buffer

Background: For convoluted reasons (all my notes have the .txt extension so Notational Velocity and iOS Simplenote will display them, but they are in org format) I want to be able to change the major mode of each note buffer when it is opened by deft. This used to be possible with the deft-text-mode var, but that was removed in d325df7 .

It seems like the deft-open-file-hook hook should be perfect for this, but as it is run outside of the (with-current-buffer ...) s-expr in deft-open-file, any mode changes (e.g. calling (org-mode)) don't actually apply to the newly opened note buffer.

Is that intentional? If not simply moving the run-hooks call inside the (with-current-buffer ...) block fixes the issue. I'm happy to submit a PR to that effect.

Thanks!

[feature request] Preview context of match

Hi there

Great utility - many thanks. It would be very useful for me (where some of my .org files are quite long) to see what part of the text has been matched, with a little context. As far as I can tell, this isn't possible with the current options, but would make a very useful feature.

That is, instead of part of the first line, can we see where the match is?

Cheers

Ian

Dayone doentry

I know it's possible to use regxp to extract the summary. Is it possible to use regxp to parse the title from Dayone donentry(which is xml file)? Thanks.

deft-text-mode had uses that deft-extensions doesn't serve...

So, my deft config was as follows: I used deft-file-extension to set the extention to .org, and then used deft-text-mode to trigger a custom minor mode that marked org buffers launched via deft as special.

I used this to do two things: it let me set up a toggle that would kill or bury all deft buffers at once, and second, so that I could inhibit the hook that cleans trailing whitespace.

Without a non-file-extension way to mark deft buffers, I can't think of an easy way to replicate this functionality. Would there be general interest in a PR restoring deft-text-mode for explicit use of attaching a minor mode to deft buffers? Or, alternately, a new variable for same?

About Performance

Hi,

I've been using deft and markdown as my note-taking tool chain for like, half a year now . Now I have 40+ notes now and it works fine.

My concern is, if my notes grow up to 500+, will there be a performance issue? I'm not familiar with Lisp and I didn't see through your code. Hope you can give us a simple answer on this.

Thanks!

Qing

No need to escape quotes for replacement characters in `deft-file-naming-rules` (Emacs 24.4)

On Emacs 24.4, the code for deft-file-naming-rules breaks with Symbol's function definition is void. Removing the slashes used to escape quotes fixes it.

(I don't know anything about Emacs, so I'm not submitted a PR. Not sure if this will break in previous versions...would be odd)

(setq deft-use-filter-string-for-filename t)
(setq deft-file-naming-rules '((noslash . "-")
                               (nospace . "-")
                               (case-fn . downcase)))

feature request: define template for all new

For my particular use case, I'd like to create a template that defines the location for org-attach to be equal to the newly created file. Something like:

for 2019-11-22.org

  • heading
    :Properties:
    :ATTACH_DIR: 2019-11-22
    :ATTACH_DIR_INHERIT: t
    :END:

[Feature Request] Hide summary for *.gpg files

For the gpg encrypted files, e.g., foo.org.gpg, it is better if Deft has an option to hide their summaries. Also, this behavior can make gpg passphrase poped until the encrypted file is actively opened instead of everytime Deft is started.

Does Deft prohibit none English searching?

I want to search with Korean language in Deft. Though my Emacs input method indicates Korean language mode, all key inputs appear in English in Deft search line only. I don't know yet whether this problem is just my Emacs settings or related in Deft. Does Deft itself prevent users from inputting none English character in search line?

Slow rendering of the files list

I have over 1000 different files in my deft directory.

Over time, deft has started to feel very slow while filtering: there is a noticeable delay with every key press while filtering files.

My first assumption was that incremental search might be slow, but a little profiling revealed that most of the time is spent in these lines of the deft-buffer-setup function:

      (if deft-current-files
          (progn
            (mapc 'deft-file-widget deft-current-files))
        (widget-insert (deft-no-files-message))))

I'm not sure if it's something wrong with my local emacs configuration: I'm running emacs-mac with font composition enabled via mac-auto-operator-composition-mode. I haven't noticed a slowdown in any other modes though.

For now, I have locally edited this function to show the first 10 files from deft-current-files. This fixes the problem for me โ€“ typing / filtering feels realtime again, without any perceived delay.

I just wanted to report this. If anyone else has noticed a similar problem, I can provide a PR which will let you customise the total number of files displayed in deft.

Wrong type argument

I have deft installed with no customizations other than file types and directory. When the buffer opens and I start typing (no matter what the search string is) I constantly get deft-filter-match-file: Wrong type argument: stringp, nil. This is emacs 24.5.1 on Mac.

feature request: request option to change deft-directory

Can we have an option to set the deft-directory runtime ? a setting like deft-set-directory!
That way we can organize huge org files into their own directory structure and also speed up.
So if my emacs init contains deft-directory to be dir1, only contents from that would be listed.
I do a deft-set-directory to dir2, then contents from only dir2 will be processed. and I will not
see contents from dir1.

Remove title and display filter in mode-line

This is a suggestion. I usually work with the latest modified file so when I bring up Deft I have to move down two lines to the first file and press RET. How about removing the first two lines altogether and display the filter in the mode-line? Then the latest modified file would only be one RET away. I do not filter often and I think this would make sense, at least as an option if not as default.

Feature request: Smarter note housekeeping (delete notes based on 'last time read')

Hello,

I'm a big fan of deft, and through my years of use I have accumulated about 600 notes. Out of all those notes, most of them (400+) are ancient notes that I will never ever use in my life again. For example, I make quick notes all the time that I use once or twice and then they just rot there.

Having so many notes makes my deft home screen almost unuseable: it's very cluttered and also a bit slower to load.

What would be the right way to do notes housekeeping? I've been thinking that I could add a (deft-housekeeping) command that deletes notes that haven't been read in over N months. So like, if I haven't opened a note for two years, it will delete it (or ask y/n to delete it).

Do you think such a thing would be useful, or in scope for deft? Or does it exist already?
Or should this be done as an emacs hook so that it's completely third party?

If this is not possible, how would you suggest I go around implementing this? (my elisp is subpar, but I can try)

deft search matches directory name of files

I've been enjoying using deft a lot lately.

I happened to notice that deft searches match the full path of files in the deft directory. For example, if deft-directory is ~/mydirectory/mynotes/, then a search for mynotes will match every note.

This seems to come from the line (insert file) in deft-filter-match-file. Using (insert (file-name-nondirectory file) would make the search match only the base name of the file (along with the title and contents), of course.

If that seems like a sensible change, I'd be happy to make a pull request for it.

[Feature Request] Option for Delimted Searching

Howdy! I've been using Deft for a while now, and I've been thinking about some of the slowness that crops up with large numbers of notes.

The deft-file-limit setting that was added recently has helped some, but I was wondering how hard it would be to implement an option to just do delimited searching rather than real-time incremental searching.

I ask, because according to the profiler, the vast majority of the slowdown I experience comes from deft-filter-increment and deft-filter-decrement/deft-filter-decrement-word calls. The actual note browser is speedy and works great -- if I could just type my search, hit enter, and let the thing come back with a result in its own time, that'd be a lot less jarring from a user experience perspective. I don't mind hitting enter and waiting for a result, but it's kinda frustrating to have the whole thing freeze up in the middle of the word you're typing.

I just really want to commit to using the hell out of Deft, but the slowdown problem is only gonna get more noticeable as I add more notes.

Quick edit: Just to be clear, I'm aware of the C-c C-l functionality, I just wish I could set the search bar to function that way directly.

[bug] deft create unwished empty file automatically

If I don't input anything to search, when I choose one file to open, deft will create an empty .org file automatically, which is not my wish.

environment:

  • macOS high sierra 10.13.4
  • GNU Emacs 26.1, I have tried both CLI and GUI version

but on ubuntu 14.04.1, this problem doesn't happen.

[question / feature request] using deft in a custom link?

I am trying to implement a zettlekasten-like system in emacs using deft and org-mode. I'm currently making a custom link type that allows for seeing all items that match that id rather than linking to a file directly. Put another way: I want a custom link type that has the effect of executing deft with the contents of the link being the search string. I feel like I essentially understand how to create a custom link type, but calling deft with an argument doesn't work. My code currently looks like this:

(org-add-link-type
               "id" 'zettel/deft-search-link)

(defun zettel/deft-search-link (uid)
; "run deft, hopefully with uid as a search term"
; "FIXME: 'deft' does not take an argument. Figure out how to do this, ask the author?"
(deft uid))

My question then, is, is there a function within deft that I could be calling that does take an argument and opens a deft buffer (preferably in other window)? If not, is it easy to modify deft to do so? Alternately, am I just going about this in a ridiculous way and there's already an easier solution?

Thanks!

If the deft browser buffer is killed, the next time you load deft, it takes longer -- and gets worse each time

So, I've noticed a weird problem with deft.

Some background and context. I'm in a situation where I'm dealing with hundreds of individual note files. Deft handles them like a champ when I limit the number of entries shown by the deft browser to something reasonable, and I've been impressed overall with how well it works. The below is my config:

(use-package deft :ensure t :config (setq deft-default-extension "org") (setq deft-file-limit 32) (setq deft-filter-only-filenames nil) (setq deft-recursive nil) :commands (deft) :bind ("<f8>" . deft) :init ) (add-hook 'deft-mode-hook (lambda () (setq display-line-numbers nil) ))

The problem is, if I kill the deft buffer and then re-open it, the length of time it hangs at "Deft initializing..." increases. On first load, it takes about half a second to initialize with 800 files in the deft directory. On second load, it's a little longer. On third load it's a second or two. On fourth load it's multiple seconds. And it just gets worse from there.

No idea what's causing it. It's really weird!

Customizing deft-open-file-other-window

Thanks for the package! I am using it to implement a Zettelkasten.

Is there a way to customize deft-open-file-other-window or C-o? The current behavior splits the window vertically. If I were to make a request for additional features, it would be for (1) a function that opens the note file in an existing other or target window without altering the existing window layout; and (2) a function very similar to deft-open-file-other-window but which splits the window horizontally rather than vertically such that the note buffer appears below the Deft buffer.

Thanks again!

Deft mode's auto-save does not play well with `ws-butler`

ws-butler is an emacs package to trim whitespace only of the lines edited by the user. It trims the whitespace 'unobtrusively' that is the file is cleaned up on the disk but the buffer still has the virtual whitespaces so that user is not interrupted with the cleanup (perhaps the project's README explains it better than me).

ws-butler tries to preserve the point in the buffer by saving current column in before-save-hook and after the whitespace is trimmed it moves to the column saved in the before-save-hook. However this fails with deft's auto-save since the auto-save code is wrapped in a save-excursion form which tries to restore the point back to the marker before the save, please note the marker is invalidated by ws-butler when it removes associated text (trailing whitespace) so apparently the point is moved back to end of visible text after the form is executed (not sure this the desired behavior of save-excursion) which different from the column moved to by ws-butler.

For example consider the following (with point indicated by |) before deft's auto-save

* Testing deft auto-save   |

After the auto-save, with ws-butler enabled, the point moves to end of visible text

* Testing deft auto-save|

As opposed to following with ws-butler enabled and buffer saved by the user, where point remains at the position before save

* Testing deft auto-save   |

I think the issue can be solved by not using save-excursion because I do not see the need to save the point, deft might only need to save the current buffer which can be achieved with save-current-buffer or with-current-buffer forms. What do you think?

BTW thanks for this package!

Deft always creates new files with .txt extension

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) 

deft-new-file-format default won't work on Windows

For those of us stuck on Windows: deft-new-file-format contains a colon (:), which causes the filename to be truncated, but emacs to report it as saved. Issuing a C-c C-c in deft then "loses" the note.

Easy to workaround by setting deft-new-file-format to "%Y-%m-%dT%H%M" (omitting the colon) in customize. But should the default be more windows-friendly? Maybe not!

support for popup rules in doom

Hello,

Thanks for all the hard work here, this is a wonderful package. One comment: I find it a bit easier to use deft in a smaller popup buffer, rather than have deft take over the entire window. AFAICT, forcing this to happen is usually done through modifying display-buffer-alist -- e.g. in doom emacs, through set-popup-rule!.

This doesn't work with deft as of now, as deft uses switch-to-buffer rather than pop-to-buffer. An easy fix is to define a new function:

(defun deft-popup ()
  "Pop *Deft* buffer and load files."
  (interactive)
  (pop-to-buffer deft-buffer)
  (if (not (eq major-mode 'deft-mode))
      (deft-mode)))

but if there is no other reason for switch-to-buffer over pop-to-buffer, perhaps that should be the default instead?

`RET` behavior after `deft-open-file-other-window`

If I use C-o to open file in another window, then when I enter a file with RET, the window created by C-o is still present. Possible to change the behavior (or add as an option)? Usually I use C-o just to browse through files, and after RET a file, I expect the other window to be closed automatically.

Line Wrap on the notes list

The notes list is not aligned properly on emacs 26.1 and deft 0.8.

As of my understanding the deft-width-offset variable was removed, right? What else could be the cause? Thank you.

Important to note: When I resize the window or refresh the buffer with "deft-refresh" it looks fine. But it happens again when you reopen the deft buffer.

deft list

Originally posted by @blackkenny in #16 (comment)

Exclude summary per file

Hello, I use Deft in a work situation and sometimes my Deft page, which lists all titles and summary, are displayed to my group. Some of my pages contain data which is somewhat sensitive. I'd like to be able to turn off displaying the summary on the Deft page on a per-file basis. Possibly adding a header like this:

#+OPTIONS: exclude-summary

Before I embark on this, is this doable today with no changes to Deft?

If not, I think I can modify deft-parse-summary to skip adding the summary if the header/tag is found.

Thanks

Is it possible to put image inside Deft note?

It is possible to be able to insert the image in a Deft note becuase image sometimes explains a lot.

One possible solution is write link inside the note view it inside a browser when you need it. (You may have to upload the image to the cloud)

Can deft-extensions define the regex extension?

I have some journal files to keep some notes with Emacs calendar ij (the idea come from Abrams
, file name with the format, %Y%m%d, 20180724, without file extension.

So, what can I let deft to look for them? How to let deft find the file with the regex "\d{8}"

org-deft-store-link returns error

Calling org-store-link in the Deft buffer returns an error:

user-error: No method for storing a link from this buffer

I am using the latest version of Deft in this repository, which includes commit #29.

I have Deft configured like this:

(use-package deft
    :ensure t
    :defer t
    :bind ("H-n" . deft)
    :config
    (setq deft-directory "~/Dropbox/work/zettelkasten")
    (setq deft-recursive t)
    (setq deft-use-filename-as-title t)
    (setq deft-use-filter-string-for-filename t)
    (setq deft-default-extension "org")
    (setq deft-extensions '("org" "md"))
    (setq deft-text-mode 'org-mode)
    (setq deft-auto-save-interval 0))

Thank you again for your work, Jason. I use Deft everyday.

Feature request: A tag code in file name based knowledge management system

I am using org files to keep notes with
https://github.com/abo-abo/plain-org-wiki/blob/master/plain-org-wiki.el
As time goes by, the file is getting bigger and bigger, which bring a lot of duplication, also makes auto save and backup files big and cause a lot more extra disk io, not good for the hard drive. :-)

So I am thinking about a purely simple tag base system:

  1. a tag datafile: (tag . value), tag is a string without blank characters, value is a numeric value, eg. ((linux . 10) (debian . 2) (emacs . 3))
  2. a notes folder: note file name is the joined string of tag values sort in ascending order, eg. a note with both linux and debian tag should be named 2-10, just plain org files without the .org extension

The search operation is simple too:

  1. a search tag function: search tag datafile with keywords separated by space to find all the matched values, each single tag uses fuzzy matching, eg. search for "dbian linx" will retrun files match the glob pattern 210*, but the file name list is converted to tag names like "1. debian linux 2. debian emacs linux", you can select the file to open with number, or you can goto 2.
  2. open them all in a temp buffer with all files inserted using https://github.com/whacked/transclusion-minor-mode , the nice thing is you can view all of them in one buffer, and maybe cut and paste from one file to another

The tag manipulation is very simple:

  1. Delete a tag: remove the tag from the datafile, replace the tag value from all notes files names, move file name the same as tag value to trash and warn the user. save the tag value to a file named available-tag-values.
  2. Add a new tag: search the tag datafile if no match, create a new tag value and associate to the tag name, the value in available-tag-values will used first.
  3. Add a tag to the current note: rename it to a name include the tag value
  4. rename a tag: just rename it in the tag datafile.

This will break big notes files into smaller ones and does not affect the viewing thanks to org translusion. However, I only have a very limited knowledge of emacs. I am looking forward to hear your opinion and on how to bring the feature to this repo.
Thank you!

Read jekyll style Front Matter for titles and other metadata

It would be sweet to use deft for writing markdown files for static sites.

The titles and other metadata for these files however are in Front Matter (YAML) rather than on the first line.

---
layout: post
title: Write Your Blog Using Deft!!!
---

Start of the post
...

deft-default-extension does not set as expected

When I set the deft-extensions user option in my .emacs init file as follows

(setq deft-extensions '("md" "txt"))

the deft-defaul-extension variable still have the old value "txt" at run time.

I think the deft-default-extension variable should be set during Deft setup process, after evaluating user's settings.

deft-extensions and the deft-find-file extension

Thanks for deft I use it for all my notes!

I have a number of file types in my notes directory but I want deft to only look for .org files. The deft-extensions variable works as advertised to filter the results in the main deft index view, but the deft-find-file() function shows other file types like .md files that match the search string. Is that the intended behavior? Is there a variable to set to filter the deft-find-file() list also?

Search just by filename

Hi Jason, fantastic product, thanks so much for putting this together.

I have a feature request; hoping for a way to search only by file name and not necessarily their content. I'm guessing that you're familiar with Merlin Mann's text file conventions so searching just by title would be a huge boon.

Thank you!

Call Deft and set filter string programmatically

First, @jrblevin thanks for a great utility!

I'm wonder what is the best way to run Deft and set the filter string programmatically?

I'm thinking about searching for word/hashtag/wikilink/selection under cursor in Deft notes much like Notational Velocity and nvALT do it for wikilinks.

Multiple directory

Dr. Blevins, thanks for this awesome work!

I have been using Deft for quite a while, it is really fantastic for keeping notes. However I find it more convenient if I could keep my notes in separate places. I'm aware of the updated feature deft-recursive, but still I may find supporting separate folders a good feature.

Proposed modification
Change deft-directory. Instead of satisfying stringp, we can make it a list, satisfying listp.

Is this a reasonable feature? May I submit a PR on it or maybe you are already working on it?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.