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

Switch to helm version of deft. #3693

Closed
punassuming opened this issue Nov 6, 2015 · 6 comments
Closed

Switch to helm version of deft. #3693

punassuming opened this issue Nov 6, 2015 · 6 comments
Labels
Enhancement ☺ stale marked as a stale issue/pr (usually by a bot)

Comments

@punassuming
Copy link
Contributor

Would be nice if we could use a helm version of deft like helm-deft over the standard deft. Would make a more seamless usage instead of having to bend deft to behave like helm. It is also not too difficult to remake a generic deft that can work on any folder. Here is another example that I have in my config to get deft like behavior:

Basic idea is to use a default directory within org-directory and show deft like window for it. Also, have other command that looks for md / org files in the current projectile-root.

Other issue with deft : can't have multiple deft directories to use with separate commands.

    (evil-leader/set-key "aop" 'org-project)
    (evil-leader/set-key "aoP" 'org-project-here)

    (defvar org-project-dir (concat org-directory "/projects/")
      "Default directory to store org project files.")

    (defvar org-project-type ".*\\.\\(md\\|org\\)$"
      "Filetypes to look at in org-project.")

    (defun org-project-fname-search ()
      "search preconfigured directory for matching files and return the
filenames as a list"
      (cl-loop for file in (directory-files org-project-dir nil org-project-type t)
               for fullpathname = (concat org-project-dir file)
               for fname = (propertize file 'face 'font-lock-keyword-face)
               for substr = (propertize (with-temp-buffer
                                          (insert-file-contents fullpathname)
                                          (buffer-string))
                                        'face 'font-lock-comment-face)
               for bufcontents = (replace-regexp-in-string "[\n\r]+" (propertize "^@" 'face 'default) substr)
               for filemod = (format-time-string "%Y-%m-%d %H:%M" (nth 5 (file-attributes fullpathname)))
               for fmod = (propertize filemod 'face 'font-lock-builtin-face)
               for lhs-length = (- (window-width) (length filemod) 1)
               ;; line format is `filename -- filetext      filedate'
               for subs = (format "%s %s"
                                  (substring
                                   (format (format "%%-%ds" lhs-length)
                                           (concat fname " -- " bufcontents))
                                   0 lhs-length)
                                  fmod)
               collect subs))

    (setq helm-source-project-fn '((name . "File Names")
                                (candidates . org-project-fname-search)
                                (action . (("Open" . org-project-open)))
                                ))

    (setq helm-source-project-fb '((name . "Create File")
                                  (dummy)
                                  (action . (("Open" . org-project-open)))
                                  ))

    (defun org-project-open (candidate)
      "Action to open file or create new"
      (find-file (concat org-project-dir
                         (if (string-match "\\(.*\\) --" candidate)
                             (match-string 1 candidate)
                           candidate))))

    (defun org-project-here ()
      "`helm' module to look at org-projects"
      (interactive)
      (let ((org-project-dir (projectile-project-root)))
        (helm
         :sources '(helm-source-project-fn helm-source-project-fb)
         :buffer "*helm projects*"
         )))

    (defun org-project ()
      "`helm' module to look at org-projects"
      (interactive)
        (helm
         :sources '(helm-source-project-fn helm-source-project-fb)
         :buffer "*helm projects*"
         :truncate-lines t
         ))
@punassuming
Copy link
Contributor Author

I will submit a PR if anyone is interested.

@mkomitee
Copy link

I've been hoping for something similar.

@punassuming
Copy link
Contributor Author

Ok, I will look into submitting something to the org layer.

@agzam
Copy link
Contributor

agzam commented Dec 1, 2015

@Ralesi why org layer? deft has it's own layer.

@punassuming
Copy link
Contributor Author

@agzam I can add it to deft I suppose, but it sort of supplants some of the usage of the deft package.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ☺ stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

No branches or pull requests

4 participants