emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Brand <michael.ch.brand@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Cc: Julien Cubizolles <j.cubizolles@free.fr>
Subject: Re: org-pdfview-open doesn't work anymore
Date: Sat, 6 Feb 2016 09:08:37 +0100	[thread overview]
Message-ID: <CALn3zoh3y+gFW_fDrmNRtwJZfpP2srx6cxcVAU6KWRha_wdCeQ@mail.gmail.com> (raw)
In-Reply-To: <87si16pylj.fsf@nicolasgoaziou.fr>

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

Hi Nicolas

On Fri, Feb 5, 2016 at 11:43 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Michael Brand <michael.ch.brand@gmail.com> writes:

>> +     ;; FIXME: Remove this check when most default installations of
>> +     ;; Emacs have at least Org 9.0.
>> +     ((wrong-number-of-arguments invalid-function)
>> +      (user-error
>> +       (concat
>> +        "Please see Org News for version 9.0 about `org-file-apps', "
>> +        "error: "
>> +        (prin1-to-string err))))))
>
> (user-error
>  "Please see Org News for version 9.0 about `org-file-apps', error: %S"
>  (nth 1 err))

The above does not provide (nth 0 err) which is the important error
type and (nth 2 err) which I find also helpful. See following zerop
examples.

What am I missing that it should not be

    ((wrong-number-of-arguments wrong-type-argument invalid-function)
     (user-error "Please see Org News for version 9.0 about \
`org-file-apps'--Lisp error: %S" err))

to get

    Please see Org News for version 9.0 about \
    `org-file-apps'--Lisp error: (wrong-number-of-arguments zerop 2)

    Please see Org News for version 9.0 about \
    `org-file-apps'--Lisp error: (wrong-type-argument numberp nil)

from

    (condition-case err (zerop nil nil) ...)

    (condition-case err (zerop nil) ...)

to mimic

    Debugger entered--Lisp error: (wrong-number-of-arguments zerop 2)

    Debugger entered--Lisp error: (wrong-type-argument numberp nil)

from

    (zerop nil nil)

    (zerop nil)

as far as possible?

I just notice that in our case at least in case of wrong-type-argument the
`cmd' is missing, so I suggest

    ((wrong-number-of-arguments wrong-type-argument invalid-function)
     (user-error "Please see Org News for version 9.0 about \
`org-file-apps'--Lisp error: The function %S leads to %S" cmd err))

for the attached intermediate patch version. For the above example of
(zerop nil) it would not only report "wrong-type-argument" and
"numberp" together with "nil" but also "zerop" which in our case is
the registered application, the source of the problem where the user
needs to look.

Michael

[-- Attachment #2: 0001-org-file-apps-add-migration-hint-for-function-signat.patch --]
[-- Type: text/x-patch, Size: 1727 bytes --]

From 873e99c9ee03594e45dd3e82d880c4b8a90d2192 Mon Sep 17 00:00:00 2001
From: Michael Brand <michael.brand@alumni.ethz.ch>
Date: Sat, 6 Feb 2016 09:03:17 +0100
Subject: [PATCH] `org-file-apps' add migration hint for function signature

* lisp/org.el (org-open-file): Add an error for when the function
signature does not match.
---
 lisp/org.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index cce4f3a..cacae0f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11325,15 +11325,21 @@ If the file does not exist, an error is thrown."
      ((functionp cmd)
       (save-match-data
 	(set-match-data link-match-data)
-	(funcall cmd file link)))
+	(condition-case err
+	    (funcall cmd file link)
+	  ;; FIXME: Remove this check when most default installations
+	  ;; of Emacs have at least Org 9.0.
+	  ((wrong-number-of-arguments wrong-type-argument invalid-function)
+	   (user-error "Please see Org News for version 9.0 about \
+`org-file-apps'--Lisp error: The function %S leads to %S" cmd err)))))
      ((consp cmd)
       ;; FIXME: Remove this check when most default installations of
       ;; Emacs have at least Org 9.0.
       ;; Heads-up instead of silently fall back to
       ;; `org-link-frame-setup' for an old usage of `org-file-apps'
       ;; with sexp instead of a function for `cmd'.
-      (user-error
-       "Please see Org News for version 9.0 about `org-file-apps'"))
+      (user-error "Please see Org News for version 9.0 about \
+`org-file-apps'--error: Deprecated usage of %S" cmd))
      (t (funcall (cdr (assq 'file org-link-frame-setup)) file)))
     (and (derived-mode-p 'org-mode)
 	 (eq old-mode 'org-mode)
-- 
2.4.9 (Apple Git-60)


  reply	other threads:[~2016-02-06  8:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-05  5:46 org-pdfview-open doesn't work anymore Julien Cubizolles
2016-02-05  8:33 ` Michael Brand
2016-02-05 13:36   ` Nicolas Goaziou
2016-02-10 12:55     ` Julien Cubizolles
2016-02-05 13:45   ` Michael Brand
2016-02-05 17:22     ` Nicolas Goaziou
2016-02-05 18:47       ` Michael Brand
2016-02-05 22:43         ` Nicolas Goaziou
2016-02-06  8:08           ` Michael Brand [this message]
2016-02-06 16:41             ` Nicolas Goaziou
2016-02-07 10:13               ` Michael Brand
2016-02-07 11:06                 ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALn3zoh3y+gFW_fDrmNRtwJZfpP2srx6cxcVAU6KWRha_wdCeQ@mail.gmail.com \
    --to=michael.ch.brand@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=j.cubizolles@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).