Advertisement
Estragon

elisp/swish integration

Sep 10th, 2011
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.32 KB | None | 0 0
  1. (defun list-notes (order)
  2.   (interactive "P")
  3.   (let* (
  4.     (find-cmd "cd /home/estragon/org/labnotes ; find . -maxdepth 3 -mindepth 3 -type d -print0")
  5.     ;; Alphabetical order with prefix arg; last-touched order without
  6.     (sorted-cmd (concat find-cmd " | xargs -0 ls -d" (if order "" "t") " -- "
  7.                 (if order " | sort -r" "")))
  8.     (note-dirs (split-string (shell-command-to-string sorted-cmd)))
  9.     (dired-note-list (cons "/home/estragon/org/labnotes/labnotes" note-dirs))
  10.     )
  11.     (require 'dired)
  12.     (switch-to-buffer (dired-internal-noselect dired-note-list "-ld"))))
  13.  
  14. (defun list-search (search-string &optional filter)
  15.   (interactive
  16.    (split-string (read-string "Search text: ") "|"))
  17.   (let* ((search-cmd-template
  18.       (concat
  19.        "cd ~/org/labnotes ; "
  20.        "swish-e -H0 -w '%s' -x '<swishdocpath>\n' | "
  21.        (if filter (format "grep '%s' | " filter) "")
  22.        "xargs ls -t --"))
  23.      (search-cmd (format search-cmd-template search-string))
  24.      (targets (split-string (shell-command-to-string search-cmd)))
  25.      (trunctargs (mapcar
  26.               (lambda (p)
  27.             (replace-regexp-in-string
  28.              "/home/estragon/org/labnotes/" "./" p))
  29.               targets))
  30.      (dired-target-list (cons "/home/estragon/org/labnotes/labnotes"
  31.                   trunctargs))
  32.      )
  33.     (require 'dired)
  34.     (switch-to-buffer (dired-internal-noselect dired-target-list "-l"))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement