[Top][All Lists]

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

Re: [Hyperbole-users] bug#36107: Global Buttons Stop Functioning When Cu

From: Robert Weiner
Subject: Re: [Hyperbole-users] bug#36107: Global Buttons Stop Functioning When Current Working Directory Changes (Forgot the Subject!)
Date: Thu, 6 Jun 2019 02:24:59 -0400

This is indeed a bug.  Evaluate this function after loading Hyperbole and I believe this will resolve it.  The default-directory was not set properly in this function.

(defun hpath:find (filename &optional display-where)
  "Edits file FILENAME using user customizable settings of display program and location.

FILENAME may start with a special prefix character which is
handled as follows:
  !filename  - execute as a non-windowed program within a shell;
  &filename  - execute as a windowed program;
  -filename  - load as an Emacs Lisp program.

Otherwise, if FILENAME matches a regular _expression_ in the alist returned by
\(hpath:get-external-display-alist), the associated external display program is invoked.
If not, `hpath:internal-display-alist' is consulted for a specialized internal
display function to use.  If no matches are found there,
`hpath:display-where-alist' is consulted using the optional argument,
DISPLAY-WHERE (a symbol) or if that is nil, the value of
`hpath:display-where', and the matching display function is used.

Allows for hash-style link references to HTML, Markdown or Emacs outline
headings of the form, <file>#<anchor-name>.

Returns non-nil iff file is displayed within a buffer (not with an external
  (interactive "FFind file: ")
  (let ((case-fold-search t)
modifier loc default-directory anchor hash path)
    (if (string-match hpath:prefix-regexp filename)
(setq modifier (aref filename 0)
      filename (substring filename (match-end 0))))
    (setq path (hpath:substitute-value
(if (string-match hpath:markup-link-anchor-regexp filename)
    (progn (setq hash t
anchor (match-string 3 filename))
   (substring filename 0 (match-end 1)))
  loc (hattr:get 'hbut:current 'loc)
  default-directory (file-name-directory
     ;; Loc may be a buffer without a file
     (if (stringp loc) loc default-directory))
  filename (hpath:absolute-to path default-directory))
    (let ((remote-filename (hpath:remote-p path)))
      (or modifier remote-filename
  (file-exists-p filename)
  (error "(hpath:find): \"%s\" does not exist" filename))
      (or modifier remote-filename
  (file-readable-p filename)
  (error "(hpath:find): \"%s\" is not readable" filename))
      ;; If filename is a remote file (not a directory, we have to copy it to
      ;; a temporary local file and then display that.
      (when (and remote-filename (not (file-directory-p remote-filename)))
(copy-file remote-filename
   (setq path (concat hpath:tmp-prefix
      (file-name-nondirectory remote-filename)))
   t t)
(setq filename (cond (anchor (concat remote-filename "#" anchor))
     (hash   (concat remote-filename "#"))
     (t path)))))
    (cond (modifier (cond ((eq modifier ?!)
   (hact 'exec-shell-cmd filename))
  ((eq modifier ?&)
   (hact 'exec-window-cmd filename))
  ((eq modifier ?-)
   (load filename)))
  (t (let ((display-executables (hpath:find-program path))
       (cond ((stringp display-executables)
      (hact 'exec-window-cmd
    (hpath:command-string display-executables
     ((hypb:functionp display-executables)
      (funcall display-executables filename)
     ((and (listp display-executables) display-executables)
      (setq executable (hpath:find-executable
      (if executable
  (hact 'exec-window-cmd
(hpath:command-string executable
(error "(hpath:find): No available executable from: %s"
     (t (setq path (hpath:validate path))
(if (null display-where)
    (setq display-where hpath:display-where))
(car (cdr (or (assq display-where
       (assq 'other-window
(if (or hash anchor) (hpath:to-markup-anchor hash anchor))

---------- Forwarded message ---------
From: <address@hidden>
Date: Wed, Jun 5, 2019 at 5:09 PM
Subject: bug#36107: Be explicit here. Make a statement or ask a question.
To: <address@hidden>

I use:  Editor:      GNU Emacs 26.1 (build 1, x86_64-w64-mingw32)

        Hyperbole:   7.0.3
        Sys Type:    x86_64-w64-mingw32
        OS Type:     windows-nt
        Window Sys:  w32
        News Reader: Gnus v5.13

[Although, I've confirmed this also happens on my Mac, with the same
Hyperbole version/Emacs version]


Howdy! I don't know if this is actually a bug, but I've run into some
weirdness with Global buttons.

Let's say that I've created a Global button to a Notes file, which lives
in my Org folder in my Home directory ("~/Org/Notes.org"). The button
metadata looks like this:

> ("Notes" nil nil link-to-file ("../Org/Notes.org") "USERNAMEHERE" "20190605:19:57:51" nil nil)

When I initially created the button, calling it with {C-h h g a}
correctly opened the document. All good so far.

Then I got to working on something else. Later, when I tried to call the
button again, and got this error:

> hpath:find: (hpath:find): "Org/Notes.org" does not exist

The file definitely exists, and hasn't been changed. But what *did*
change was my current working directory.

The problem -- if it actually *is* a problem -- seems to be in the
assumption Hyperbole makes that I'm always calling global buttons inside
the "~/.hyperb" folder.

When I work with other files, and change what folder I'm in, Hyperbole
doesn't seem to know to change the current working directory back to
"~/.hyperb" -- so, when I call global buttons, it's calling the relative
path ("..Org/Notes.org") from the place I'm currently working (say,
"~/Work/Project 1").

If I changed the button metadata to read ("~/Org/Notes.org") the button
immediately works as intended -- but having to manually alter every
global button seems like odd behavior.

Like I said, I don't know if this is a bug, or what. I usually assume
it's me doing something dumb to make this stuff happen -- but to try to
eliminate user error I quickly wrote an empty ".emacs" file that *only*
loaded Hyperbole, and I still saw the same behavior.

No idea! Hyperbole seems cool -- if it's something I'm doing wrong, I'd
love to fix it!

Bug-hyperbole mailing list

reply via email to

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