Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 5ad84a8f06e1aebf706ba1e6a9573142b0b57ac0 @PoshHsu committed Jul 23, 2012
Showing with 163 additions and 0 deletions.
  1. +43 −0 init.el
  2. +120 −0 taglist.el
43 init.el
@@ -0,0 +1,43 @@
+(require 'package)
+(add-to-list 'package-archives
+ '("marmalade" . "http://marmalade-repo.org/packages/") t)
+(package-initialize)
+
+(when (not package-archive-contents)
+ (package-refresh-contents))
+
+(defvar my-packages '(starter-kit starter-kit-eshell starter-kit-bindings)
+ "A list of packages to ensure are installed at launch.")
+
+(dolist (p my-packages)
+ (when (not (package-installed-p p))
+ (package-install p)))
+
+(global-set-key "\C-x\C-m" 'execute-extended-command)
+(global-set-key "\C-c\C-m" 'execute-extended-command)
+
+(global-set-key "\C-w" 'backward-kill-word)
+(global-set-key "\C-x\C-k" 'kill-region)
+
+;;(setq stack-trace-on-error t)
+;;(add-to-list 'load-path "~/.emacs.d/ecb")
+;;(require 'ecb)
+;;(ecb-activate)
+;;(ecb-byte-compile)
+
+(load-theme 'deeper-blue)
+
+(load-file "~/.emacs.d/taglist.el")
+
+(custom-set-variables
+ ;; custom-set-variables was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ '(jabber-account-list (quote (("poshenghsu@gmail.com" (:network-server . "talk.google.com") (:port . 5223) (:connection-type . ssl)) ("poshenghsu@chat.facebook.com" (:network-server . "chat.facebook.com") (:port . 5222) (:connection-type . starttls))))))
+(custom-set-faces
+ ;; custom-set-faces was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ )
@@ -0,0 +1,120 @@
+(defvar taglist-mode-hook nil)
+
+(defvar taglist-keywords
+ (list (list "^\t\\([^ ]*\\) \\(L[0-9]+\\) *\\(.*\\)$" 1 font-lock-keyword-face)
+ (list "^\t\\([^ ]*\\) \\(L[0-9]+\\) *\\(.*\\)$" 2 font-lock-comment-delimiter-face)
+ (list "^\t\\([^ ]*\\) \\(L[0-9]+\\) *\\(.*\\)$" 3 font-lock-function-name-face)))
+
+(defvar taglist-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "RET") 'taglist-jump)
+ (define-key map (kbd "q") 'taglist-quit)
+ map))
+
+(defvar taglist-window nil)
+(defvar taglist-current 0)
+
+(defun taglist nil
+ (interactive)
+ (require 'speedbar)
+ (require 'imenu)
+
+ ;; Clear cache
+ (setq imenu--index-alist nil)
+
+ (let ((source-buffer (current-buffer))
+ (current-line (line-number-at-pos)))
+
+ ;; Create a buffer
+ (if (get-buffer "*etags tmp*")
+ (kill-buffer "*etags tmp*"))
+ (if (get-buffer "*etags list*")
+ (kill-buffer "*etags list*"))
+ (set-buffer (get-buffer-create "*etags list*"))
+
+ ;; Call speedbar tags
+ (setq taglist-current 0)
+ (taglist-fill-tags
+ source-buffer
+ (cddr (speedbar-fetch-dynamic-tags
+ (buffer-file-name source-buffer)))
+ ""
+ current-line)
+
+ (goto-char (point-min))
+ (forward-line (1- taglist-current))
+
+ (setq taglist-window (split-window-vertically))
+ (set-window-buffer taglist-window "*etags list*")
+ (select-window taglist-window)
+ (taglist-mode)))
+
+(defun taglist-fill-tags (source-buffer tags prefix current)
+ (while tags
+ (if (integer-or-marker-p (cdar tags))
+ (let ((tag-line
+ (with-current-buffer source-buffer
+ (line-number-at-pos (cdar tags)))))
+ (insert (format "\t%s L%-5d%s%s\n"
+ (buffer-name source-buffer)
+ tag-line
+ prefix
+ (caar tags)))
+ (when (>= current tag-line)
+ (setq taglist-current
+ (1+ taglist-current))))
+ (let* ((dir-string (caar tags))
+ (marker (get-text-property 0 'org-imenu-marker dir-string))
+ (tag-line 0))
+ (if marker
+ (setq tag-line
+ (with-current-buffer source-buffer
+ (line-number-at-pos marker))))
+ (insert (format "\t%s L%-5d%s%s\n"
+ (buffer-name source-buffer)
+ tag-line
+ prefix
+ (caar tags)))
+ (when (>= current tag-line)
+ (setq taglist-current
+ (1+ taglist-current)))
+ (taglist-fill-tags source-buffer
+ (cdar tags)
+ (concat "+-" prefix)
+ current)))
+ (setq tags (cdr tags))))
+
+(defun taglist-kill nil
+ (if (and taglist-window
+ (window-live-p taglist-window)
+ (not (one-window-p)))
+ (delete-window taglist-window))
+ (setq taglist-window nil)
+ (kill-buffer "*etags list*"))
+
+(defun taglist-jump nil
+ (interactive)
+ (let ((line (buffer-substring
+ (line-beginning-position)
+ (line-end-position))))
+ (string-match "^\t\\([^ ]*\\) L\\([0-9]+\\)[^0-9]" line)
+ (taglist-kill)
+ (switch-to-buffer (match-string 1 line))
+ (goto-char (point-min))
+ (forward-line (1- (string-to-number (match-string 2 line))))))
+
+(defun taglist-quit nil
+ (interactive)
+ (taglist-kill))
+
+(defun taglist-mode nil
+ (interactive)
+ (kill-all-local-variables)
+ (use-local-map taglist-map)
+ (setq major-mode 'taglist-mode)
+ (setq mode-name "Tag-List")
+ (setq font-lock-defaults
+ (list 'taglist-keywords))
+ (run-mode-hooks 'taglist-mode-hook))
+
+(provide 'taglist)

0 comments on commit 5ad84a8

Please sign in to comment.