From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.help Subject: Re: Go to Emacs-Lisp Definition Date: Tue, 22 Sep 2009 11:21:31 +0200 Message-ID: References: <324be851-a60d-4762-8a61-e070e4ee59ac@d34g2000vbm.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1253614687 25799 80.91.229.12 (22 Sep 2009 10:18:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Sep 2009 10:18:07 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 22 12:18:00 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Mq2Rb-0000XJ-7r for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Sep 2009 12:17:59 +0200 Original-Received: from localhost ([127.0.0.1]:48475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mq2Ra-0000mU-5b for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Sep 2009 06:17:58 -0400 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.kpnqwest.it!news.kpnqwest.it.POSTED!not-for-mail Original-NNTP-Posting-Date: Tue, 22 Sep 2009 04:21:32 -0500 Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:ogXxhdY9/iaXfOV3smcCRsfKYTU= Original-Lines: 98 X-Usenet-Provider: http://www.giganews.com Original-NNTP-Posting-Host: 212.46.180.77 Original-X-Trace: sv3-i6AWotaud/wQlbvQfJ7Pcf5VglEe8L9yu++wzpPtgZ9BZ4799ek2XX3e/hJYVufNVBq/GFWAbzlH7cX!n3gV4xu3RTVY1Zc+SqKY2C5O0W+dlJ0q+RiPVxhSKTeCfC9yHaJSr1+hxWFUWQ== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Original-Xref: news.stanford.edu gnu.emacs.help:173250 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:68373 Archived-At: * Nordlöw [2009-09-22 11:13+0200] writes: > Has anyone implemented a go to (lookup) definition of an Emacs-Lisp > symbol: function, variable, face, etc kind of like find-tag but using > Emacs own symbol database (hash-table)? > > I know that I can achieve this in Vanilla Emacs with C-h f,v, but > direct jump (M-.) would be more user efficient! I have this in my .emacs. It's some random elisp hacking stuff. Pick what you need. Helmut (defun elisp-disassemble (function) (interactive (list (function-called-at-point))) (disassemble function)) (defun elisp-pp (sexp) (with-output-to-temp-buffer "*Pp Eval Output*" (pp sexp) (with-current-buffer standard-output (emacs-lisp-mode)))) (defun elisp-macroexpand (form) (interactive (list (form-at-point 'sexp))) (elisp-pp (macroexpand form))) (defun elisp-macroexpand-all (form) (interactive (list (form-at-point 'sexp))) (elisp-pp (cl-macroexpand-all form))) (defun elisp-push-point-marker () (require 'etags) (cond ((featurep 'xemacs) (push-tag-mark)) (t (ring-insert find-tag-marker-ring (point-marker))))) (defun elisp-pop-found-function () (interactive) (cond ((featurep 'xemacs) (pop-tag-mark nil)) (t (pop-tag-mark)))) (defun elisp-find-definition (name) "Jump to the definition of the function (or variable) at point." (interactive (list (thing-at-point 'symbol))) (cond (name (let ((symbol (intern-soft name)) (search (lambda (fun sym) (let* ((r (save-excursion (funcall fun sym))) (buffer (car r)) (point (cdr r))) (cond ((not point) (error "Found no definition for %s in %s" name buffer)) (t (switch-to-buffer buffer) (goto-char point) (recenter 1))))))) (cond ((fboundp symbol) (elisp-push-point-marker) (funcall search 'find-function-noselect symbol)) ((boundp symbol) (elisp-push-point-marker) (funcall search 'find-variable-noselect symbol)) (t (message "Symbol not bound: %S" symbol))))) (t (message "No symbol at point")))) (defun elisp-bytecompile-and-load () (interactive) (or buffer-file-name (error "The buffer must be saved in a file first")) (require 'bytecomp) ;; Recompile if file or buffer has changed since last compilation. (when (and (buffer-modified-p) (y-or-n-p (format "save buffer %s first? " (buffer-name)))) (save-buffer)) (let ((filename (expand-file-name buffer-file-name))) (with-temp-buffer (byte-compile-file filename t)))) (defvar elisp-extra-keys '(((kbd "C-c d") 'elisp-disassemble) ((kbd "C-c m") 'elisp-macroexpand) ((kbd "C-c M") 'elisp-macroexpand-all) ((kbd "C-c C-c") 'compile-defun) ((kbd "C-c C-k") 'elisp-bytecompile-and-load) ((kbd "C-c C-l") 'load-file) ((kbd "C-c p") 'pp-eval-last-sexp) ((kbd "M-.") 'elisp-find-definition) ((kbd "M-,") 'elisp-pop-found-function) ((kbd "C-c <") 'list-callers))) (dolist (binding elisp-extra-keys) (let ((key (eval (car binding))) (val (eval (cadr binding)))) (define-key emacs-lisp-mode-map key val) (define-key lisp-interaction-mode-map key val)))