全部博文(43)
分类: LINUX
2011-09-15 22:00:30
(defgroup wlint nil
"wlint interface for (X)Emacs.
Using wlint, you can easily search for where symbols are used and defined.
It is designed to answer questions like:
Where is this variable used?
What is the value of this preprocessor symbol?
Where is this function in the source files?
What functions call this function?
What functions are called by this function?
Where does the message \"out of space\" come from?
Where is this source file in the directory structure?
What files include this header file?
"
:prefix "wlint-"
:group 'tools)
(defvar wlint-output-buffer-name "*wlint*"
"The name of the wlint output buffer.")
(defvar wlint-input-buffer-name "_LINT.TMP"
"The name of the wlint output buffer.")
;;;;
;;;; Faces for fontification
;;;;
(defcustom wlint-use-face t
"*Whether to use text highlighting (ॆ la font-lock) or not."
:group 'wlint
:type '(boolean))
(defface wlint-file-face
'((((class color) (background dark))
(:foreground "yellow"))
(((class color) (background light))
(:foreground "blue"))
(t (:bold t)))
"Face used to highlight file name in the *wlint* buffer."
:group 'wlint)
(defface wlint-function-face
'((((class color) (background dark))
(:foreground "cyan"))
(((class color) (background light))
(:foreground "magenta"))
(t (:bold t)))
"Face used to highlight function name in the *wlint* buffer."
:group 'wlint)
(defface wlint-line-face
'((((class color) (background dark))
(:foreground "green"))
(((class color) (background light))
(:foreground "black"))
(t (:bold nil)))
"Face used to highlight the rest of line in the *wlint* buffer."
:group 'wlint)
(defface wlint-mouse-face
'((((class color) (background dark))
(:foreground "white" :background "blue"))
(((class color) (background light))
(:foreground "white" :background "blue"))
(t (:bold nil)))
"Face used when mouse pointer is within the region of an entry."
:group 'wlint)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Internal functions and variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar wlint-common-text-plist
(let (plist)
(setq plist (plist-put plist 'mouse-face 'wlint-mouse-face))
plist)
"List of common text properties to be added to the entry line.")
(defcustom wlint-name-line-width -30
"*The width of the combined \"function name:line number\" field in the
cscope results buffer. If negative, the field is left-justified."
:type 'integer
:group 'wlint)
(defcustom wlint-overlay-arrow-string "=>"
"*The overlay string to use when displaying arrow overlays."
:type 'string
:group 'wlint)
(defun wlint-insert-with-text-properties (text filename &optional line-number)
"Insert an entry with given TEXT, add entry attributes as text properties.
The text properties to be added:
- common property: mouse-face,
- properties are used to open target file and its location: wlint-file,
wlint-line-number"
(let ((plist wlint-common-text-plist)
beg end)
(setq beg (point))
(insert text)
(setq end (point)
plist (plist-put plist 'wlint-file filename))
(if line-number
(progn
(if (stringp line-number)
(setq line-number (string-to-number line-number)))
(setq plist (plist-put plist 'wlint-line-number line-number))
))
(add-text-properties beg end plist)
))
(defvar wlint-list-entry-hook nil
"*Hook run after wlint-list-entry-mode entered.")
(defun wlint-list-entry-mode ()
"Major mode for jumping/showing entry from the list in the *cscope* buffer.
}"
(use-local-map wlint-list-entry-keymap)
(setq buffer-read-only t
mode-name "wlint"
major-mode 'wlint-list-entry-mode
overlay-arrow-string wlint-overlay-arrow-string)
(or overlay-arrow-position
(setq overlay-arrow-position (make-marker)))
(run-hooks 'wlint-list-entry-hook))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; functions in *cscope* buffer which lists the search results
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun wlint-select-entry-other-window ()
"Display the entry at point in other window, select the window.
Push current point on mark ring and select the entry window."
(interactive)
(let ((file (get-text-property (point) 'wlint-file))
(line-number (get-text-property (point) 'wlint-line-number))
window)
(setq window (wlint-show-entry-internal file line-number t))
(if (windowp window)
(select-window window))
))
(defun wlint-process-filter()
(setq wlint-input-buffer-name (find-file "C:/Lint/_LINT.TMP" ))
(set-buffer (get-buffer-create wlint-input-buffer-name))
(goto-char (point-min))
(setq outbuf (get-buffer-create wlint-output-buffer-name))
(set-buffer outbuf)
(setq buffer-read-only nil)
(erase-buffer)
(setq counter 0)
(while (setq line (wlint-buffer-get-line wlint-input-buffer-name))
(if (string-match "^\\([^ ]*()" line)
(progn
(setq file (substring line (match-beginning 1)
(- (match-end 1) 1))
line-number (substring line (match-beginning 2)
(match-end 2)))
(wlint-insert-with-text-properties
(wlint-make-entry-line (concat (number-to-string counter) ":") line-number line)
file
line-number)
(setq counter (1+ counter)))
(insert line))
(insert "\n")
)
(set-buffer-modified-p nil)
(wlint-list-entry-mode)
(kill-buffer wlint-input-buffer-name)
)
(wlint-process-filter)