help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature Request: Auto-jumping to source file (.el) upon elisp error


From: Andreas Röhler
Subject: Re: Feature Request: Auto-jumping to source file (.el) upon elisp error
Date: Mon, 10 Dec 2007 19:47:21 +0100
User-agent: KMail/1.9.5

Am Montag, 10. Dezember 2007 15:27 schrieb Nordlöw:
> On Dec 10, 1:14 pm, Stefan Kamphausen <address@hidden> wrote:
> > Hi,
> >
> > "Nordlöw" <address@hidden> 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 address@hidden 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?")))

;;;;;;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]