unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21950: 25.1.50; find-lisp-object-file-name sometimes cannot find file-name
@ 2015-11-18 10:48 Tino Calancha
  2015-11-18 15:59 ` Stephen Leake
  2016-05-09  1:52 ` bug#21950: 25.1.50; Show the filename where an alias is defined Tino Calancha
  0 siblings, 2 replies; 8+ messages in thread
From: Tino Calancha @ 2015-11-18 10:48 UTC (permalink / raw)
  To: 21950

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



* lisp/help-fns.el (find-lisp-object-file-name):
   Restrict second argument of symbol-file to just 'defvar 'defface 'defun

emacs -Q:
;; following returns nil (it should be the value of file)
(let ((alias 'd)
       (def   'dired)
       (file  (expand-file-name "test-alias-v25.1.50-tmp.el"
 			       user-emacs-directory)))
   (with-temp-file file
     (insert (format "(defalias '%s '%s)"
 		    (symbol-name alias)
 		    (symbol-name def))))
   (load-file file)
   (find-lisp-object-file-name alias def))

[-- Attachment #2: Type: text/plain, Size: 768 bytes --]

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 4e0bfee..af9b918 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -223,7 +223,10 @@ find-lisp-object-file-name
                          ;; FIXME: Why do we have this weird "If TYPE is the
                          ;; value returned by `symbol-function' for a function
                          ;; symbol" exception?
-			 object (or (if (symbolp type) type) 'defun)))))
+                       object (if (and (symbolp type)
+                                       (memq type (list 'defvar 'defface)))
+                                  type
+                                'defun)))))
     (cond
      (autoloaded
       ;; An autoloaded function: Locate the file since `symbol-function'

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

* bug#21950: 25.1.50; find-lisp-object-file-name sometimes cannot find file-name
  2015-11-18 10:48 bug#21950: 25.1.50; find-lisp-object-file-name sometimes cannot find file-name Tino Calancha
@ 2015-11-18 15:59 ` Stephen Leake
  2015-11-19  0:27   ` Tino Calancha
  2016-05-09  1:52 ` bug#21950: 25.1.50; Show the filename where an alias is defined Tino Calancha
  1 sibling, 1 reply; 8+ messages in thread
From: Stephen Leake @ 2015-11-18 15:59 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 21950

Tino Calancha <f92capac@gmail.com> writes:

> ;; following returns nil (it should be the value of file)
> (let ((alias 'd)
>       (def   'dired)
>       (file  (expand-file-name "test-alias-v25.1.50-tmp.el"
> 			       user-emacs-directory)))
>   (with-temp-file file
>     (insert (format "(defalias '%s '%s)"
> 		    (symbol-name alias)
> 		    (symbol-name def))))
>   (load-file file)
>   (find-lisp-object-file-name alias def))

You are passing 'dired as the TYPE argument, which is undocumented, so
it's not surprising it doesn't do what you want.

How did you stumble into this?

-- 
-- Stephe





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

* bug#21950: 25.1.50; find-lisp-object-file-name sometimes cannot find file-name
  2015-11-18 15:59 ` Stephen Leake
@ 2015-11-19  0:27   ` Tino Calancha
  2015-11-19 17:47     ` Stephen Leake
  0 siblings, 1 reply; 8+ messages in thread
From: Tino Calancha @ 2015-11-19  0:27 UTC (permalink / raw)
  To: Stephen Leake; +Cc: Tino Calancha, 21950


Hi Stephe,

> You are passing 'dired as the TYPE argument, which is undocumented, so
> it's not surprising it doesn't do what you want.

Exactly, that was my example to pointing out the issue.
In emacs version < 25 find-lisp-object-file-name automatically 
replaced 'dired by 'defun, so the user file containing the alias is
always found.

> How did you stumble into this?
I have code relying of such behaviour (probably i should rewrite it in a 
more robust way): it was working fine in emacs24 but since i moved to 
emacs25 doesn't work at all.

Tino





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

* bug#21950: 25.1.50; find-lisp-object-file-name sometimes cannot find file-name
  2015-11-19  0:27   ` Tino Calancha
@ 2015-11-19 17:47     ` Stephen Leake
  2015-11-20 10:20       ` Tino Calancha
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Leake @ 2015-11-19 17:47 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 21950

Tino Calancha <f92capac@gmail.com> writes:

> Hi Stephe,
>
>> You are passing 'dired as the TYPE argument, which is undocumented, so
>> it's not surprising it doesn't do what you want.
>
> Exactly, that was my example to pointing out the issue.
> In emacs version < 25 find-lisp-object-file-name automatically
> replaced 'dired by 'defun, so the user file containing the alias is
> always found.

That change was made in this commit:

   commit 24b7f77581c7eefe484db6cbbd661c04460c66aa
   Committer : Stefan Monnier <monnier@iro.umontreal.ca>
   CommitDate: Fri Jan 16 22:52:15 2015 -0500

      Improve handling of doc-strings and describe-function for cl-generic

So I'm guessing we don't want to change it back.

>> How did you stumble into this?
> I have code relying of such behaviour (probably i should rewrite it in
> a more robust way): 

Yes. Please give that a try. If it's difficult, we can see if there is a
way to satisfy both your use case and cl-generic.

-- 
-- Stephe





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

* bug#21950: 25.1.50; find-lisp-object-file-name sometimes cannot find file-name
  2015-11-19 17:47     ` Stephen Leake
@ 2015-11-20 10:20       ` Tino Calancha
  2015-11-20 10:48         ` bug#21950: [SPAM UNSURE] " Stephen Leake
  0 siblings, 1 reply; 8+ messages in thread
From: Tino Calancha @ 2015-11-20 10:20 UTC (permalink / raw)
  To: Stephen Leake; +Cc: Tino Calancha, 21950

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



> That change was made in this commit:
>
>   commit 24b7f77581c7eefe484db6cbbd661c04460c66aa
>   Committer : Stefan Monnier <monnier@iro.umontreal.ca>
>   CommitDate: Fri Jan 16 22:52:15 2015 -0500
>
>      Improve handling of doc-strings and describe-function for cl-generic
>
> So I'm guessing we don't want to change it back.
>
> Yes. Please give that a try. If it's difficult, we can see if there is a
> way to satisfy both your use case and cl-generic.

Thank you for your answer.
Im sure the change is for better, im just worry that we lost a small
piece of information in describe-function: for instance, without the 
change, (describe-function 'not) returns in buffer *Help*:

not is an alias for ‘null’ in ‘subr.el’.

(not OBJECT)

Return t if OBJECT is nil, and return nil otherwise.

But now, we get:

not is an alias for ‘null’.

(not OBJECT)

Return t if OBJECT is nil, and return nil otherwise.

I found nice to know if the alias is an user alias or an Emacs one,
and to see in which file is defined. But if people are fine with this 
small detail then would be also ok for me.

Tino

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

* bug#21950: [SPAM UNSURE] Re: bug#21950: 25.1.50; find-lisp-object-file-name sometimes cannot find file-name
  2015-11-20 10:20       ` Tino Calancha
@ 2015-11-20 10:48         ` Stephen Leake
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Leake @ 2015-11-20 10:48 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 21950

Tino Calancha <f92capac@gmail.com> writes:

> I found nice to know if the alias is an user alias or an Emacs one,
> and to see in which file is defined.

Yes. I'll see if I can fix this.

--
-- Stephe





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

* bug#21950: 25.1.50; Show the filename where an alias is defined
  2015-11-18 10:48 bug#21950: 25.1.50; find-lisp-object-file-name sometimes cannot find file-name Tino Calancha
  2015-11-18 15:59 ` Stephen Leake
@ 2016-05-09  1:52 ` Tino Calancha
  2016-06-07 20:46   ` Glenn Morris
  1 sibling, 1 reply; 8+ messages in thread
From: Tino Calancha @ 2016-05-09  1:52 UTC (permalink / raw)
  To: stephen_leake; +Cc: Tino Calancha, 21950



> I found nice to know if the alias is an user alias or an Emacs one,
> and to see in which file is defined.
Below a new patch that solves the issue about showing the filename
where the alias is defined.  This patch does not interfere with
the Stefan commit mentioned in this thread.


In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.30)
  of 2016-05-06 built on calancha-pc
Repository revision: 80bea210ff14a64daa1d71765983aa3baa149555


From a139bc5e9c3f4c737abf342b903095684fb38edc Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac@gmail.com>
Date: Mon, 9 May 2016 10:19:33 +0900
Subject: [PATCH] Show the filename where an alias is defined

* help-fns (describe-function-1): Pass 'defun as TYPE
to 'find-lisp-object-file-name' when OBJECT
is an alias (Bug#21950).
---
  lisp/help-fns.el | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index d1c8b2d..6ba9140 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -526,7 +526,9 @@ describe-function-1
  	 (sig-key (if (subrp def)
                        (indirect-function real-def)
                      real-def))
-	 (file-name (find-lisp-object-file-name function def))
+	 (file-name (find-lisp-object-file-name function
+                                                (or (and aliased 'defun)
+                                                    def)))
           (pt1 (with-current-buffer (help-buffer) (point)))
  	 (beg (if (and (or (byte-code-function-p def)
  			   (keymapp def)
-- 
2.8.1






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

* bug#21950: 25.1.50; Show the filename where an alias is defined
  2016-05-09  1:52 ` bug#21950: 25.1.50; Show the filename where an alias is defined Tino Calancha
@ 2016-06-07 20:46   ` Glenn Morris
  0 siblings, 0 replies; 8+ messages in thread
From: Glenn Morris @ 2016-06-07 20:46 UTC (permalink / raw)
  To: 21950-done

Version: 25.1

Tino Calancha wrote:

> Below a new patch that solves the issue about showing the filename
> where the alias is defined.  This patch does not interfere with
> the Stefan commit mentioned in this thread.

Thanks; applied with minor tweak.





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

end of thread, other threads:[~2016-06-07 20:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-18 10:48 bug#21950: 25.1.50; find-lisp-object-file-name sometimes cannot find file-name Tino Calancha
2015-11-18 15:59 ` Stephen Leake
2015-11-19  0:27   ` Tino Calancha
2015-11-19 17:47     ` Stephen Leake
2015-11-20 10:20       ` Tino Calancha
2015-11-20 10:48         ` bug#21950: [SPAM UNSURE] " Stephen Leake
2016-05-09  1:52 ` bug#21950: 25.1.50; Show the filename where an alias is defined Tino Calancha
2016-06-07 20:46   ` Glenn Morris

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).