github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

nakkaya / emacs

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 1
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Switch Branches (1)
    • master ✓
  • Switch Tags (0)
  • Branch List
Sending Request…

Emacs init files — Read more

  Cancel

http://nakkaya.com

  Cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

org-mode 
nakkaya (author)
Sat Mar 06 14:07:22 -0800 2010
commit  56b9580bf52e28367b919883d9453f671df6ecc5
tree    d4041eff6e7b64545ff8efc40775545c52a3c61d
parent  d70028b16f69e8d729ed608bca509f268eda44f6
emacs / int / searchDown.el int/searchDown.el
100644 91 lines (77 sloc) 2.597 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
;; Author: Nurullah Akkaya (nurullah@nakkaya.com)
;; Location: http://nakkaya.com
;; Version: 1.0
 
;;
;; This module will traverse a directory tree and
;; search for a regex. Exclude directories and
;; exclude files variables determine which files
;; and directories will be skipped.
;;
;; Installation
;; Load this file from emacs
;; (load "searchDown.el")
;; and call na-search-down using M-x
;;
 
;;folders to be skipped from search
(setq na-exclude-directories (list ".svn" "."))
;;file extensions to be skipped from search.
(setq na-exclude-files (list ".class" ".ico" ".png" ".jar" ".exe" "TAGS" ".DS_Store" ))
 
(defun na-search-down( directory )
(interactive "DDirectory: ")
 
(setq regex (read-string "Regex: "))
(setq foundFiles (list ) )
(na-traverse-directory directory )
 
(switch-to-buffer "*Result*")
(with-current-buffer "*Result*"
(erase-buffer))
(set (make-local-variable 'truncate-lines) t)
 
(dolist (file foundFiles )
  (na-search-file-for-regex file regex )))
 
(defun na-traverse-directory( directory )
;(print directory)
(dolist (node (directory-files directory t ) )
  (if (file-directory-p node)
      (progn
;;check against excluded directories
(setq exclude-directory nil)
(dolist (item na-exclude-directories)
(if (string= item (substring node (- 0 (string-width item)) ))
(setq exclude-directory t)))
;;traverse directory
(if (equal exclude-directory nil )
(na-traverse-directory node ))
)
    ;;add found file
    (progn
      ;;(print node)
      ;;check against excluded files
      (setq exclude-file nil)
      (dolist (item na-exclude-files)
(if (string= item (substring node (- 0 (string-width item)) ))
(setq exclude-file t)))
      (if (equal exclude-file nil )
(setq foundFiles (cons node foundFiles)))))))
 
;; (defun na-test()
;; (interactive)
;; (setq foundFiles (list ) )
;; (na-traverse-directory "~/Projects/")
;; (print foundFiles))
 
 
(defun na-search-file-for-regex( file regex )
(setq na-fileName (car (reverse (split-string file "/"))))
(setq na-fileName-printed nil)
(with-temp-buffer
(beginning-of-buffer)
(insert-file-contents file )
(beginning-of-buffer)
(while (re-search-forward regex nil t)
(setq end (match-end 0))
 
(goto-char end)
(setq line (thing-at-point 'line))
(setq lineNumber (what-line))
 
(with-current-buffer "*Result*"
(end-of-buffer)
 
(if (equal na-fileName-printed nil)
(progn
(insert (concat "\n" na-fileName "\n") )
(setq na-fileName-printed t)))
(insert (concat "\t" lineNumber "\t" line ))))))
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server