all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Feature Request: Auto-jumping to source file (.el) upon elisp error
@ 2007-12-10  8:54 Nordlöw
  2007-12-10  9:59 ` Stefan Kamphausen
  0 siblings, 1 reply; 9+ messages in thread
From: Nordlöw @ 2007-12-10  8:54 UTC (permalink / raw)
  To: help-gnu-emacs

My highest priority Emacs feature request:

When I encounter an error in elisp code I always wonder: Is there a
way for Emacs to automatically split my elisp-error window in two and
replace one of the windows with the relating source file and jump to
position in that buffer where the error occurrred, like we are used to
with practically all other languages/IDEs?

Thanks in advance,
Nordlöw

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Feature Request: Auto-jumping to source file (.el) upon elisp error
  2007-12-10  8:54 Feature Request: Auto-jumping to source file (.el) upon elisp error Nordlöw
@ 2007-12-10  9:59 ` Stefan Kamphausen
  2007-12-10 10:40   ` Nordlöw
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Kamphausen @ 2007-12-10  9:59 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

"Nordlöw" <per.nordlow@gmail.com> writes:

> My highest priority Emacs feature request:
>
> When I encounter an error in elisp code I always wonder: Is there a
> way for Emacs to automatically split my elisp-error window in two and
> replace one of the windows with the relating source file and jump to
> position in that buffer where the error occurrred, like we are used to
> with practically all other languages/IDEs?

to me it seems that just the right thing happens.

For example, when I start a un-customized emacs:

shell> emacs -q

put the following into my scratch buffer:
----------------------------------------------------------------------
(defun produce-an-error ()
  (interactive)
  (goto-char))

(setq debug-on-error t)

(produce-an-error)
----------------------------------------------------------------------

and do a M-x eval-current-buffer I get a second window showing a
backtrace:
----------------------------------------------------------------------
Debugger entered--Lisp error: (wrong-number-of-arguments goto-char 0)
  (goto-char)
  produce-an-error()
  eval-current-buffer()
  call-interactively(eval-current-buffer)
  execute-extended-command(nil)
  call-interactively(execute-extended-command)
----------------------------------------------------------------------

The cute thing is that all known elisp functions (as opposed to
C-builtins) will be clickable to jump to the function definition.
Since I may be interested in various levels of the whole backtrace
this is way better than having the program decide which one will be my
point of interest.

Just my 2ct.

Regards,
Stefan
-- 
Stefan Kamphausen --- http://www.skamphausen.de
a blessed +42 regexp of confusion (weapon in hand)
You hit. The format string crumbles and turns to dust.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Feature Request: Auto-jumping to source file (.el) upon elisp  error
  2007-12-10  9:59 ` Stefan Kamphausen
@ 2007-12-10 10:40   ` Nordlöw
  2007-12-10 12:14     ` Stefan Kamphausen
  0 siblings, 1 reply; 9+ messages in thread
From: Nordlöw @ 2007-12-10 10:40 UTC (permalink / raw)
  To: help-gnu-emacs

On Dec 10, 10:59 am, Stefan Kamphausen <ska...@gmx.net> wrote:
> Hi,
>
> "Nordlöw" <per.nord...@gmail.com> writes:
> > My highest priority Emacs feature request:
>
> > When I encounter an error in elisp code I always wonder: Is there a
> > way for Emacs to automatically split my elisp-error window in two and
> > replace one of the windows with the relating source file and jump to
> > position in that buffer where the error occurrred, like we are used to
> > with practically all other languages/IDEs?
>
> to me it seems that just the right thing happens.
>
> For example, when I start a un-customized emacs:
>
> shell> emacs -q
>
> put the following into my scratch buffer:
> ----------------------------------------------------------------------
> (defun produce-an-error ()
>   (interactive)
>   (goto-char))
>
> (setq debug-on-error t)
>
> (produce-an-error)
> ----------------------------------------------------------------------
>
> and do a M-x eval-current-buffer I get a second window showing a
> backtrace:
> ----------------------------------------------------------------------
> Debugger entered--Lisp error: (wrong-number-of-arguments goto-char 0)
>   (goto-char)
>   produce-an-error()
>   eval-current-buffer()
>   call-interactively(eval-current-buffer)
>   execute-extended-command(nil)
>   call-interactively(execute-extended-command)
> ----------------------------------------------------------------------
>
> The cute thing is that all known elisp functions (as opposed to
> C-builtins) will be clickable to jump to the function definition.
> Since I may be interested in various levels of the whole backtrace
> this is way better than having the program decide which one will be my
> point of interest.
>
> Just my 2ct.
>
> Regards,
> Stefan
> --
> Stefan Kamphausen ---http://www.skamphausen.de
> a blessed +42 regexp of confusion (weapon in hand)
> You hit. The format string crumbles and turns to dust.

But the top-most function, in your case produce-an-error(), is neither
clickable nor mentioned about its file/buffer-origin in the Debugger
output. This is sad because this is what the user/developer wants to
see first in order to most easily understand the top-most (call-stack)
context of the problem.

/Nordlöw

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Feature Request: Auto-jumping to source file (.el) upon elisp error
  2007-12-10 10:40   ` Nordlöw
@ 2007-12-10 12:14     ` Stefan Kamphausen
  2007-12-10 14:27       ` Nordlöw
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Kamphausen @ 2007-12-10 12:14 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

"Nordlöw" <per.nordlow@gmail.com> writes:

> But the top-most function, in your case produce-an-error(), is neither
> clickable nor mentioned about its file/buffer-origin in the Debugger
> output. This is sad because this is what the user/developer wants to
> see first in order to most easily understand the top-most (call-stack)
> context of the problem.

you are right that the function is not clickable in the backtrace if
being added interactively.  It does work however, if it was written
into a separate file and then loaded via (e.g.) M-x load-file.

Does that fit your needs?

Regards,
Stefan
-- 
Stefan Kamphausen --- http://www.skamphausen.de
a blessed +42 regexp of confusion (weapon in hand)
You hit. The format string crumbles and turns to dust.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Feature Request: Auto-jumping to source file (.el) upon elisp  error
  2007-12-10 12:14     ` Stefan Kamphausen
@ 2007-12-10 14:27       ` Nordlöw
  2007-12-10 18:47         ` Andreas Röhler
       [not found]         ` <mailman.4842.1197312462.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 9+ messages in thread
From: Nordlöw @ 2007-12-10 14:27 UTC (permalink / raw)
  To: help-gnu-emacs

On Dec 10, 1:14 pm, Stefan Kamphausen <ska...@gmx.net> wrote:
> Hi,
>
> "Nordlöw" <per.nord...@gmail.com> writes:
> > But the top-most function, in your case produce-an-error(), is neither
> > clickable nor mentioned about its file/buffer-origin in the Debugger
> > output. This is sad because this is what the user/developer wants to
> > see first in order to most easily understand the top-most (call-stack)
> > context of the problem.
>
> you are right that the function is not clickable in the backtrace if
> being added interactively.  It does work however, if it was written
> into a separate file and then loaded via (e.g.) M-x load-file.
>
> Does that fit your needs?
>
> Regards,
> Stefan
> --
> Stefan Kamphausen ---http://www.skamphausen.de
> a blessed +42 regexp of confusion (weapon in hand)
> You hit. The format string crumbles and turns to dust.

Okey, thanks for your answer!

Is it still possible to make Emacs automatically open top-most source
code context in another window?

Thanks again,
Nordlöw

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Feature Request: Auto-jumping to source file (.el) upon elisp error
  2007-12-10 14:27       ` Nordlöw
@ 2007-12-10 18:47         ` Andreas Röhler
  2007-12-10 19:11           ` Feature Request: Auto-jumping to source file (.el) upon elisperror Drew Adams
       [not found]         ` <mailman.4842.1197312462.18990.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 9+ messages in thread
From: Andreas Röhler @ 2007-12-10 18:47 UTC (permalink / raw)
  To: help-gnu-emacs

Am Montag, 10. Dezember 2007 15:27 schrieb Nordlöw:
> On Dec 10, 1:14 pm, Stefan Kamphausen <ska...@gmx.net> wrote:
> > Hi,
> >
> > "Nordlöw" <per.nord...@gmail.com> writes:
> > > But the top-most function, in your case produce-an-error(), is neither
> > > clickable nor mentioned about its file/buffer-origin in the Debugger
> > > output. This is sad because this is what the user/developer wants to
> > > see first in order to most easily understand the top-most (call-stack)
> > > context of the problem.
> >
> > you are right that the function is not clickable in the backtrace if
> > being added interactively.  It does work however, if it was written
> > into a separate file and then loaded via (e.g.) M-x load-file.
> >
> > Does that fit your needs?
> >
> > Regards,
> > Stefan
> > --
> > Stefan Kamphausen ---http://www.skamphausen.de
> > a blessed +42 regexp of confusion (weapon in hand)
> > You hit. The format string crumbles and turns to dust.
>
> Okey, thanks for your answer!
>
> Is it still possible to make Emacs automatically open top-most source
> code context in another window?
>
> Thanks again,
> Nordlöw

I use an adapted function `aktualisieren', which takes
arguments as C-h f does, but then opens the source if
available, narrowed to function mentioned. Code below.

Might that be a step forward?

Andreas Röhler

(defun aktualisieren (function)
  "Go to FUNCTION (a symbol), narrow to region."
  (interactive
   (let ((fn (save-excursion
	       (beginning-of-defun)
	       (forward-word 2)
	       (if (featurep 'xemacs)
		   (function-at-point)
		 (function-called-at-point))))
	 val)
     (list (intern-soft (completing-read (if fn
					     (format "Describe function (default %s): " fn)
					   "Describe function: ")
					 obarray 'fboundp t nil nil (symbol-name fn))))))
  (if (file-readable-p
       ;; No effect, why?
       (condition-case nil
	   (symbol-file function)
	 (error "Keine Quelldatei gefunden")))
      (let* ((datei (symbol-file function)))
	(cond
	 ((file-exists-p (concat (file-name-sans-extension datei) ".el"))
	  (find-file (concat (file-name-sans-extension datei) ".el")))
	 ((file-exists-p (concat (file-name-sans-extension datei) ".el.gz"))
	  (find-file (concat (file-name-sans-extension datei) ".el.gz")))
	 ((file-exists-p (concat datei ".gz"))
	  (find-file (concat datei ".gz")))
	 (t (error (concat "Keine Quelle vorhanden"))))
	;; 2007-06-03 a.roehler@web.de changed section end	
	(widen)
	(goto-char (point-min))
	(cond 
	 ((search-forward (concat "(defun " (symbol-name function)" ") nil t) ;; 
Leerzeichen, um "-" in Funktionsnamen auszuschlie��ßen
	  (progn
	    (narrow-to-region (progn (beginning-of-defun) (point))(progn 
(end-of-defun) (point)))
	    (delete-other-windows))) 
	 ((progn (goto-char (point-min))
		 (re-search-forward (concat "(defalias '" (symbol-name 
function) " '\\([^)]+\\)") nil t 1))
	  (progn
	    (message " %s" (match-string-no-properties 1))
	    (goto-char (point-min))
	    (search-forward (match-string-no-properties 1))))
	 ((progn (goto-char (point-min))
		 (re-search-forward (concat "\(define-.+" (symbol-name function) " *$") nil 
t 1))
	  (message " %s" (match-string-no-properties 0)))
	 (t (goto-char (point-min)))))
    (message "%s" "No file assigned, self-made function?")))

;;;;;;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Feature Request: Auto-jumping to source file (.el) upon elisperror
  2007-12-10 18:47         ` Andreas Röhler
@ 2007-12-10 19:11           ` Drew Adams
  2007-12-11  7:05             ` Andreas Röhler
  0 siblings, 1 reply; 9+ messages in thread
From: Drew Adams @ 2007-12-10 19:11 UTC (permalink / raw)
  To: Andreas Röhler, help-gnu-emacs

> I use an adapted function `aktualisieren', which takes
> arguments as C-h f does, but then opens the source if
> available, narrowed to function mentioned. Code below.

Just bind `find-function' to a key?

Or, if you really want the code narrowed to the function definition, write a command that calls `find-function' and then narrows. 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Feature Request: Auto-jumping to source file (.el) upon elisperror
  2007-12-10 19:11           ` Feature Request: Auto-jumping to source file (.el) upon elisperror Drew Adams
@ 2007-12-11  7:05             ` Andreas Röhler
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Röhler @ 2007-12-11  7:05 UTC (permalink / raw)
  To: help-gnu-emacs

Am Montag, 10. Dezember 2007 20:11 schrieb Drew Adams:
> > I use an adapted function `aktualisieren', which takes
> > arguments as C-h f does, but then opens the source if
> > available, narrowed to function mentioned. Code below.
>
> Just bind `find-function' to a key?
>
> Or, if you really want the code narrowed to the function definition, write
> a command that calls `find-function' and then narrows.
>
>

You are perfectly right, thanks.

Andreas Röhler

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Feature Request: Auto-jumping to source file (.el) upon elisp  error
       [not found]         ` <mailman.4842.1197312462.18990.help-gnu-emacs@gnu.org>
@ 2007-12-11  9:40           ` Nordlöw
  0 siblings, 0 replies; 9+ messages in thread
From: Nordlöw @ 2007-12-11  9:40 UTC (permalink / raw)
  To: help-gnu-emacs

On Dec 10, 7:47 pm, Andreas Röhler <andreas.roeh...@online.de> wrote:
> Am Montag, 10. Dezember 2007 15:27 schrieb Nordlöw:
>
>
>
> > On Dec 10, 1:14 pm, Stefan Kamphausen <ska...@gmx.net> wrote:
> > > Hi,
>
> > > "Nordlöw" <per.nord...@gmail.com> writes:
> > > > But the top-most function, in your case produce-an-error(), is neither
> > > > clickable nor mentioned about its file/buffer-origin in the Debugger
> > > > output. This is sad because this is what the user/developer wants to
> > > > see first in order to most easily understand the top-most (call-stack)
> > > > context of the problem.
>
> > > you are right that the function is not clickable in the backtrace if
> > > being added interactively.  It does work however, if it was written
> > > into a separate file and then loaded via (e.g.) M-x load-file.
>
> > > Does that fit your needs?
>
> > > Regards,
> > > Stefan
> > > --
> > > Stefan Kamphausen ---http://www.skamphausen.de
> > > a blessed +42 regexp of confusion (weapon in hand)
> > > You hit. The format string crumbles and turns to dust.
>
> > Okey, thanks for your answer!
>
> > Is it still possible to make Emacs automatically open top-most source
> > code context in another window?
>
> > Thanks again,
> > Nordlöw
>
> I use an adapted function `aktualisieren', which takes
> arguments as C-h f does, but then opens the source if
> available, narrowed to function mentioned. Code below.
>
> Might that be a step forward?
>
> Andreas Röhler
>
> (defun aktualisieren (function)
>   "Go to FUNCTION (a symbol), narrow to region."
>   (interactive
>    (let ((fn (save-excursion
>                (beginning-of-defun)
>                (forward-word 2)
>                (if (featurep 'xemacs)
>                    (function-at-point)
>                  (function-called-at-point))))
>          val)
>      (list (intern-soft (completing-read (if fn
>                                              (format "Describe function (default %s): " fn)
>                                            "Describe function: ")
>                                          obarray 'fboundp t nil nil (symbol-name fn))))))
>   (if (file-readable-p
>        ;; No effect, why?
>        (condition-case nil
>            (symbol-file function)
>          (error "Keine Quelldatei gefunden")))
>       (let* ((datei (symbol-file function)))
>         (cond
>          ((file-exists-p (concat (file-name-sans-extension datei) ".el"))
>           (find-file (concat (file-name-sans-extension datei) ".el")))
>          ((file-exists-p (concat (file-name-sans-extension datei) ".el.gz"))
>           (find-file (concat (file-name-sans-extension datei) ".el.gz")))
>          ((file-exists-p (concat datei ".gz"))
>           (find-file (concat datei ".gz")))
>          (t (error (concat "Keine Quelle vorhanden"))))
>         ;; 2007-06-03 a.roeh...@web.de changed section end
>         (widen)
>         (goto-char (point-min))
>         (cond
>          ((search-forward (concat "(defun " (symbol-name function)" ") nil t) ;;
> Leerzeichen, um "-" in Funktionsnamen auszuschlie��ßen
>           (progn
>             (narrow-to-region (progn (beginning-of-defun) (point))(progn
> (end-of-defun) (point)))
>             (delete-other-windows)))
>          ((progn (goto-char (point-min))
>                  (re-search-forward (concat "(defalias '" (symbol-name
> function) " '\\([^)]+\\)") nil t 1))
>           (progn
>             (message " %s" (match-string-no-properties 1))
>             (goto-char (point-min))
>             (search-forward (match-string-no-properties 1))))
>          ((progn (goto-char (point-min))
>                  (re-search-forward (concat "\(define-.+" (symbol-name function) " *$") nil
> t 1))
>           (message " %s" (match-string-no-properties 0)))
>          (t (goto-char (point-min)))))
>     (message "%s" "No file assigned, self-made function?")))
>
> ;;;;;;

Can I make this happen automatically upon error?

Automation, automation, automation...

Thanks again,
Nordlöw

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-12-11  9:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-10  8:54 Feature Request: Auto-jumping to source file (.el) upon elisp error Nordlöw
2007-12-10  9:59 ` Stefan Kamphausen
2007-12-10 10:40   ` Nordlöw
2007-12-10 12:14     ` Stefan Kamphausen
2007-12-10 14:27       ` Nordlöw
2007-12-10 18:47         ` Andreas Röhler
2007-12-10 19:11           ` Feature Request: Auto-jumping to source file (.el) upon elisperror Drew Adams
2007-12-11  7:05             ` Andreas Röhler
     [not found]         ` <mailman.4842.1197312462.18990.help-gnu-emacs@gnu.org>
2007-12-11  9:40           ` Feature Request: Auto-jumping to source file (.el) upon elisp error Nordlöw

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.