auctex-devel
[Top][All Lists]
Advanced

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

Re: tex.el compiler warnings


From: Tassilo Horn
Subject: Re: tex.el compiler warnings
Date: Wed, 19 Aug 2020 18:38:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Arash Esbati <arash@gnu.org> writes:

Hi Arash,

the defvars look good to me.

> @@ -1188,15 +1233,16 @@ entry in `TeX-view-program-list-builtin'."
>      (error "PDF Tools only work with PDF output"))
>    (add-hook 'pdf-sync-backward-redirect-functions
>             #'TeX-source-correlate-handle-TeX-region)
> -  (if (and TeX-source-correlate-mode
> -          (fboundp 'pdf-sync-forward-search))
> -      (with-current-buffer (or (when TeX-current-process-region-p
> -                                (get-file-buffer (TeX-region-file t)))
> -                              (current-buffer))
> -       (pdf-sync-forward-search))
> -    (let ((pdf (concat file "." (TeX-output-extension))))
> -      (pop-to-buffer (or (find-buffer-visiting pdf)
> -                        (find-file-noselect pdf))))))
> +  (with-no-warnings
> +    (if (and TeX-source-correlate-mode
> +            (fboundp 'pdf-sync-forward-search))
> +       (with-current-buffer (or (when TeX-current-process-region-p
> +                                  (get-file-buffer (TeX-region-file t)))
> +                                (current-buffer))
> +         (pdf-sync-forward-search))
> +      (let ((pdf (concat file "." (TeX-output-extension))))
> +       (pop-to-buffer (or (find-buffer-visiting pdf)
> +                          (find-file-noselect pdf)))))))

Why is that needed?  As far as I see, that function only complains about
variables defined by AUCTeX itself which you can also defvar, no?

In TeX-pdf-tools-sync-view:
tex.el:1187:11: Warning: reference to free variable ‘TeX-PDF-mode’
tex.el:1191:12: Warning: reference to free variable
    ‘TeX-source-correlate-mode’
tex.el:1193:38: Warning: reference to free variable
    ‘TeX-current-process-region-p’
tex.el:1197:24: Warning: reference to free variable ‘file’

Of course with the exception of the variable `file' set via dynamic
scoping which is one hindrance for switching to lexical-binding and as
such should produce a compiler warning.  Maybe we should add a

  (defvar TeX-file nil)

and bind that in addition to the undeclared `file', make AUCTeX itself
only use TeX-file (and update the docs), and eventually omit binding
`file' in the mid-term future.

> @@ -1216,38 +1262,39 @@ for the Evince-compatible entries in
>  DE is the name of the desktop environment, APP is the name of
>  viewer."
>    (require 'url-util)
> -  (let* ((uri (concat "file://" (url-encode-url
> -                                (expand-file-name
> -                                 (concat file "." (TeX-output-extension))))))
> -        (owner (dbus-call-method
> -                :session (format "org.%s.%s.Daemon" de app)
> -                (format "/org/%s/%s/Daemon" de app)
> -                (format "org.%s.%s.Daemon" de app)
> -                "FindDocument"
> -                uri
> -                t)))
> -    (if owner
> -       (with-current-buffer (or (when TeX-current-process-region-p
> -                                  (get-file-buffer (TeX-region-file t)))
> -                                (current-buffer))
> -         (dbus-call-method
> -          :session owner
> -          (format "/org/%s/%s/Window/0" de app)
> -          (format "org.%s.%s.Window" de app)
> -          "SyncView"
> -          (buffer-file-name)
> -          (list :struct :int32 (1+ (TeX-current-offset))
> -                ;; FIXME: Using `current-column' here is dubious.
> -                ;; Most of CJK letters count as occupying 2 columns,
> -                ;; so the column number is not equal to the number of
> -                ;; the characters counting from the beginning of a
> -                ;; line.  What is the right number to specify here?
> -                ;; number of letters? bytes in UTF8? or other?
> -                :int32 (1+ (current-column)))
> -          :uint32 0)
> -          (when TeX-view-evince-keep-focus
> -            (select-frame-set-input-focus (selected-frame))))
> -      (error "Couldn't find the %s instance for %s" (capitalize app) uri))))
> +  (with-no-warnings
> +    (let* ((uri (concat "file://" (url-encode-url
> +                                  (expand-file-name
> +                                   (concat file "." 
> (TeX-output-extension))))))
> +          (owner (dbus-call-method
> +                  :session (format "org.%s.%s.Daemon" de app)
> +                  (format "/org/%s/%s/Daemon" de app)
> +                  (format "org.%s.%s.Daemon" de app)
> +                  "FindDocument"
> +                  uri
> +                  t)))
> +      (if owner
> +         (with-current-buffer (or (when TeX-current-process-region-p
> +                                    (get-file-buffer (TeX-region-file t)))
> +                                  (current-buffer))
> +           (dbus-call-method
> +            :session owner
> +            (format "/org/%s/%s/Window/0" de app)
> +            (format "org.%s.%s.Window" de app)
> +            "SyncView"
> +            (buffer-file-name)
> +            (list :struct :int32 (1+ (TeX-current-offset))
> +                  ;; FIXME: Using `current-column' here is dubious.
> +                  ;; Most of CJK letters count as occupying 2 columns,
> +                  ;; so the column number is not equal to the number of
> +                  ;; the characters counting from the beginning of a
> +                  ;; line.  What is the right number to specify here?
> +                  ;; number of letters? bytes in UTF8? or other?
> +                  :int32 (1+ (current-column)))
> +            :uint32 0)
> +            (when TeX-view-evince-keep-focus
> +              (select-frame-set-input-focus (selected-frame))))
> +       (error "Couldn't find the %s instance for %s" (capitalize app) 
> uri)))))

Same here.

In TeX-evince-sync-view-1:
tex.el:1221:43: Warning: reference to free variable ‘file’
tex.el:1230:40: Warning: reference to free variable
    ‘TeX-current-process-region-p’

Ah, or is it complaining about the dbus functions?  I guess they are
only available on GNU/Linux (and you didn't turn off dbus support).  But
anyway, I would like to keep warnings about abusing dynamic scope such
as the warning about `file' here.

Bye,
Tassilo




reply via email to

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