Chinaunix首页 | 论坛 | 博客
  • 博客访问: 183304
  • 博文数量: 43
  • 博客积分: 1150
  • 博客等级: 少尉
  • 技术积分: 450
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-29 15:52
文章分类

全部博文(43)

文章存档

2012年(18)

2011年(24)

2008年(1)

分类: LINUX

2011-11-13 22:29:43

 

(defcustom nsearch-symbol-chars "_-"
  "*A string containing legal characters in a symbol.
The current syntax table should really be used for this."
  :type 'string
  :group 'netsearch)

(defcustom nsearch-filename-chars "-.,/A-Za-z0-9_~!@#$%&+=\\\\"
  "*A string containing legal characters in a symbol.
The current syntax table should really be used for this."
  :type 'string
  :group 'nsearch)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst nsearch-running-in-xemacs (string-match "XEmacs\\|Lucid" emacs-version))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defcustom nsearch-no-mouse-prompts nil
  "*If non-nil, use the symbol under the cursor instead of prompting.
Do not prompt for a value, except for when seaching for a egrep pattern
or a file."
  :type 'boolean
  :group 'nsearch)


(defun eskip-chars-backward (symbol)
  (if (re-search-backward symbol 20 t)
      (eskip-chars-backward symbol)
    nil)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun nsearch-extract-symbol-at-cursor (extract-filename)
  (let* ( (symbol-chars (if extract-filename
       nsearch-filename-chars
     nsearch-symbol-chars))
   (symbol-char-regexp (concat "[" symbol-chars "]"))
   )
    (save-excursion
      (progn
 (buffer-substring-no-properties
  (progn
    (if (not (looking-at symbol-char-regexp))
        (re-search-backward "" nil t))
    (skip-chars-backward symbol-chars )
    (point))
  (progn
    (skip-chars-forward symbol-chars )
    (point)
  ))
 (if (or (not sym)
   (string-match " " sym))
       (setq sym (current-word))
     sym)
       ))
    ))

(defun nsearch-prompt-for-symbol (prompt extract-filename)
  "Prompt the user for a cscope symbol."
  (let (sym)
    (setq sym (nsearch-extract-symbol-at-cursor extract-filename))
    (if (or (not sym)
     (string= sym "")
     (not (and nsearch-running-in-xemacs
        nsearch-no-mouse-prompts current-mouse-event
        (or (mouse-event-p current-mouse-event)
     (misc-user-event-p current-mouse-event))))
     ;; Always prompt for symbol in dired mode.
     (eq major-mode 'dired-mode)
     )
 (setq sym (read-from-minibuffer prompt sym))
      sym)
    ))

(defun nsearch-find (symbol)
  "Find a symbol's global definition."
  (interactive (list
  (nsearch-prompt-for-symbol "Find this: " nil)
  ))
  (let ((nsearch-symbol symbol))
    (setq nsearch-symbol (concat "=" nsearch-symbol))
    (message "%s" nsearch-symbol)
    (start-process "iexplorer" (get-buffer-create "temp" )
     "C:/Program Files/Internet Explorer/iexplore.exe" nsearch-symbol)
    ))


(global-set-key (kbd "C-c n") 'nsearch-find)

;;测试

阅读(1383) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~