unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A suggestion...
@ 2007-05-14 10:16 David Kastrup
  2007-05-17  4:31 ` Herbert Euler
  0 siblings, 1 reply; 4+ messages in thread
From: David Kastrup @ 2007-05-14 10:16 UTC (permalink / raw)
  To: emacs-devel


When doing something like C-h f for a function, one gets displayed a
hyperlink to the corresponding source file.

Now there is not rarely the situation that one actually wants not to
go to the Elisp file in load-path, but rather the actual source file.

It happens that .elc files have a header similar to the following:

;ELC.
;;; Compiled by dak@lola.quinscape.zz on Mon May 14 12:09:35 2007
;;; from file /rep/emacs/lisp/gnus/mml2015.el
;;; in Emacs version 23.0.51
;;; with all optimizations.

The information is sufficient for determining whether the compilation
happened on the current machine by the current user, and if so, what
the actual source file has been.

So in this particular case, I'd prefer if, without further
configuration and ado, I'd be landed in the corresponding source file
if it is still present on the given machine.

Since I have several packages I build and install from the respective
CVS source archives, having this work automatically would be quite
nice.

-- 
David Kastrup

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

* RE: A suggestion...
  2007-05-14 10:16 A suggestion David Kastrup
@ 2007-05-17  4:31 ` Herbert Euler
  2007-05-17  7:14   ` David Kastrup
  0 siblings, 1 reply; 4+ messages in thread
From: Herbert Euler @ 2007-05-17  4:31 UTC (permalink / raw)
  To: dak, emacs-devel

>When doing something like C-h f for a function, one gets displayed a
>hyperlink to the corresponding source file.
>
>Now there is not rarely the situation that one actually wants not to
>go to the Elisp file in load-path, but rather the actual source file.
>
>It happens that .elc files have a header similar to the following:
>
>;ELC.
>;;; Compiled by dak@lola.quinscape.zz on Mon May 14 12:09:35 2007
>;;; from file /rep/emacs/lisp/gnus/mml2015.el
>;;; in Emacs version 23.0.51
>;;; with all optimizations.
>
>The information is sufficient for determining whether the compilation
>happened on the current machine by the current user, and if so, what
>the actual source file has been.
>
>So in this particular case, I'd prefer if, without further
>configuration and ado, I'd be landed in the corresponding source file
>if it is still present on the given machine.
>
>Since I have several packages I build and install from the respective
>CVS source archives, having this work automatically would be quite
>nice.

I agree.  M-. now always creates buffers like "subr.el<2>", which
is not good.

Regards,
Guanpeng Xu

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.com/

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

* Re: A suggestion...
  2007-05-17  4:31 ` Herbert Euler
@ 2007-05-17  7:14   ` David Kastrup
  2007-05-17 14:28     ` Jan Djärv
  0 siblings, 1 reply; 4+ messages in thread
From: David Kastrup @ 2007-05-17  7:14 UTC (permalink / raw)
  To: Herbert Euler; +Cc: emacs-devel

"Herbert Euler" <herberteuler@hotmail.com> writes:

>>When doing something like C-h f for a function, one gets displayed a
>>hyperlink to the corresponding source file.
>>
>>Now there is not rarely the situation that one actually wants not to
>>go to the Elisp file in load-path, but rather the actual source file.
>>
>>It happens that .elc files have a header similar to the following:
>>
>>;ELC.
>>;;; Compiled by dak@lola.quinscape.zz on Mon May 14 12:09:35 2007
>>;;; from file /rep/emacs/lisp/gnus/mml2015.el
>>;;; in Emacs version 23.0.51
>>;;; with all optimizations.
>>
>>The information is sufficient for determining whether the compilation
>>happened on the current machine by the current user, and if so, what
>>the actual source file has been.
>>
>>So in this particular case, I'd prefer if, without further
>>configuration and ado, I'd be landed in the corresponding source file
>>if it is still present on the given machine.
>>
>>Since I have several packages I build and install from the respective
>>CVS source archives, having this work automatically would be quite
>>nice.
>
> I agree.  M-. now always creates buffers like "subr.el<2>", which
> is not good.

I have in my own personal .emacs file the following which mitigates
the problem but requires manual configuration for every package you
work with.  And at my Emacs at the workplace, I have not yet adapted
.emacs, so I was annoyed again.  All the info for an automatic
solution is actually in-place in the compiled Lisp files.  Even when
some installation procedure copies _only_ the compiled files.

(defcustom find-function-transform-list
  `((,(expand-file-name ".." data-directory)
     "/home/tmp/emacs")
    ("/usr/local/emacs-21/share/emacs/site-lisp/preview"
     "/home/tmp/auctex/preview")
    ("/usr/local/emacs-21/share/emacs/site-lisp/auctex"
     "/home/tmp/auctex/preview"
     "/home/tmp/auctex"))
  "File prefixes to transform `find-function-source-path'."
  :group 'find-file
  :type '(repeat (list string (repeat string))))


(defadvice find-library-name (around find-function-transform activate)
  (let ((find-function-source-path (or find-function-source-path load-path)))
    (let (lst case-fold-search lst2 len elt2)
      (setq find-function-source-path
	    (dolist (elt find-function-source-path (nreverse lst))
	      (setq lst2 find-function-transform-list)
	      (catch 'found
		(while lst2
		  (setq elt2 (pop lst2)
			len (length (car elt2)))
		  (when (or (string= elt (car elt2))
			    (and (< len (length elt))
				 (string= (substring elt 0 (1+ len))
					  (concat (car elt2) "/"))))
		    (while (setq elt2 (cdr elt2))
		      (push (concat (car elt2) (substring elt len)) lst))
		    (throw 'found t)))
		(push elt lst)))))
    ad-do-it))


-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: A suggestion...
  2007-05-17  7:14   ` David Kastrup
@ 2007-05-17 14:28     ` Jan Djärv
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Djärv @ 2007-05-17 14:28 UTC (permalink / raw)
  To: David Kastrup; +Cc: Herbert Euler, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2004 bytes --]

David Kastrup skrev:
> "Herbert Euler" <herberteuler@hotmail.com> writes:
> 
>>> When doing something like C-h f for a function, one gets displayed a
>>> hyperlink to the corresponding source file.
>>>
>>> Now there is not rarely the situation that one actually wants not to
>>> go to the Elisp file in load-path, but rather the actual source file.
>>>
>>> It happens that .elc files have a header similar to the following:
>>>
>>> ;ELC.
>>> ;;; Compiled by dak@lola.quinscape.zz on Mon May 14 12:09:35 2007
>>> ;;; from file /rep/emacs/lisp/gnus/mml2015.el
>>> ;;; in Emacs version 23.0.51
>>> ;;; with all optimizations.
>>>
>>> The information is sufficient for determining whether the compilation
>>> happened on the current machine by the current user, and if so, what
>>> the actual source file has been.
>>>
>>> So in this particular case, I'd prefer if, without further
>>> configuration and ado, I'd be landed in the corresponding source file
>>> if it is still present on the given machine.
>>>
>>> Since I have several packages I build and install from the respective
>>> CVS source archives, having this work automatically would be quite
>>> nice.
>> I agree.  M-. now always creates buffers like "subr.el<2>", which
>> is not good.
> 
> I have in my own personal .emacs file the following which mitigates
> the problem but requires manual configuration for every package you
> work with.  And at my Emacs at the workplace, I have not yet adapted
> .emacs, so I was annoyed again.  All the info for an automatic
> solution is actually in-place in the compiled Lisp files.  Even when
> some installation procedure copies _only_ the compiled files.
> 

I want this feature as well.  I came up with the following patch.  It probably
don't work correctly with non-ascii file names, I think one should check file
coding there somewhere.  Also I don't check user and machine since I share
installation and source directories with different user names (long story) on
different machines.

	Jan D.



[-- Attachment #2: help-fns.diff --]
[-- Type: text/x-patch, Size: 1293 bytes --]

Index: lisp/help-fns.el
*** lisp/help-fns.el.~1.96.~	2007-01-24 20:52:15.000000000 +0100
--- lisp/help-fns.el	2007-05-17 16:23:46.000000000 +0200
***************
*** 232,237 ****
--- 232,250 ----
  	      libname)
  	  file))))
  
+ (defun find-source-lisp-file (file-name)
+   (let* ((elc-file (locate-file (concat file-name "c") load-path))
+ 	 (str (if (and elc-file (file-readable-p elc-file))
+ 		  (with-temp-buffer 
+ 		    (insert-file-contents elc-file nil 0 256)
+ 		    (buffer-string))))
+ 	 (src-file (and str
+ 			(string-match ";;; from file \\(.*\\.el\\)" str)
+ 			(match-string 1 str))))
+     (if (and src-file (file-readable-p src-file))
+ 	src-file
+       file-name)))
+ 
  ;;;###autoload
  (defun describe-function-1 (function)
    (let* ((def (if (symbolp function)
***************
*** 309,314 ****
--- 322,331 ----
        ;; but that's completely wrong when the user used load-file.
        (princ (if (eq file-name 'C-source) "C source code" file-name))
        (princ "'")
+       ;; See if lisp files are present where they where installed from.
+       (if (not (eq file-name 'C-source))
+ 	  (setq file-name (find-source-lisp-file file-name)))
+ 
        ;; Make a hyperlink to the library.
        (with-current-buffer standard-output
          (save-excursion

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

end of thread, other threads:[~2007-05-17 14:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-14 10:16 A suggestion David Kastrup
2007-05-17  4:31 ` Herbert Euler
2007-05-17  7:14   ` David Kastrup
2007-05-17 14:28     ` Jan Djärv

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).