Subject: help-xref-button in header line doesn't work (PATCH attached)

From: Vaidheeswaran C <[email-masked]>
Date: Thu, 09 Jul 2015 23:04:07 +0530

1. Copy this snippet to scratch buffer and eval it.

(define-button-type 'hello-world
  :supertype 'help-xref
  'help-function (lambda ()
		   (message "Hello World")))

(setq header-line-format
      (make-text-button "Hello World" nil 'type 'hello-world))

2. Click on the header buton

3. Note the following stack trace

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p
(#("Hello World" 0 11 (button (t) category hello-world-button)) . 10))
  button-start((#("Hello World" 0 11 (button (t) category
hello-world-button)) . 10))
  help-button-action((#("Hello World" 0 11 (button (t) category
hello-world-button)) . 10))
  button-activate((#("Hello World" 0 11 (button (t) category
hello-world-button)) . 10) t)
  push-button((mouse-2 (#<window 18 on *Backtrace*> header-line (103 .
14) 11071944 (#("Hello World" 0 11 (button (t) category
hello-world-button)) . 10) nil (10 . -1) nil (3 . 14) (10 . 18))))
  funcall-interactively(push-button (mouse-2 (#<window 18 on
*Backtrace*> header-line (103 . 14) 11071944 (#("Hello World" 0 11
(button (t) category hello-world-button)) . 10) nil (10 . -1) nil (3 .
14) (10 . 18))))
  call-interactively(push-button nil nil)
  command-execute(push-button)

----------------------------------------------------------------

This bug is related to bug#12817: 24.2; The button library does not
work on the header line.  The sole difference here is that button is a
help-xref button.

See http://lists.gnu.org/archive/html/bug-gnu-emacs/2012-12/msg00203.html

The related commit is 24fc948039

----------------------------------------------------------------

Without getting in to nitty gritties of the "area buttons", the fix is
fairly simple once you notice that `help-do-xref' doesn't use the
first argument.

See the attached patch.

----------------------------------------------------------------

(I am working on a dictionary client for Emacs.  I will circulate the
module -- I call it edictc.el -- in another week.  The package uses
xref links in header line, FWIW.)

diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index e1fc9fd..ac74e03 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -107,7 +107,7 @@ The format is (FUNCTION ARGS...).")
 
 (defun help-button-action (button)
   "Call BUTTON's help function."
-  (help-do-xref (button-start button)
+  (help-do-xref nil
 		(button-get button 'help-function)
 		(button-get button 'help-args)))