unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* A strange auto typesetting problem when using auctex.
@ 2021-06-14  3:45 Hongyi Zhao
  2021-06-14  6:12 ` Hongyi Zhao
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Hongyi Zhao @ 2021-06-14  3:45 UTC (permalink / raw)
  To: auctex-devel; +Cc: help-gnu-emacs

On Ubuntu 20.04, I use the latest git master Emacs version compiled by
myself. I install and load auctex's git master version with the
following bootstrap code in `~/.emacs.d/init.el':

;;Bootstrap auctex via straight
(straight-use-package
 `( auctex :type git :host nil :repo
"https://git.savannah.gnu.org/git/auctex.git"
    :pre-build ,(pcase system-type
                (`berkeley-unix '("gmake"))
                (_ '(
                    ;("bash" "-c" "cd ~/.emacs.d/straight/repos/auctex")
                    ("./autogen.sh")
                    ("./configure")
                    ("make")
                    ("sudo" "make" "install"))))))

(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
;;; auctex config ends here

Then I try to test auctex with the following LaTeX sample file:

%% LaTeX sample file
\documentclass{paper}
\usepackage{hyperref}
\begin{document}
See
\href{http://www.fulviofrisone.com/attachments/article/480/Ballentine%20L.%20Quantum%20mechanics%20-%20a%20modern%20development%20(1998)(T)(673s).pdf}{page
98}
\end{document}
%% LaTeX sample file ends here

When I put the point after the `{page 98}' and hit RET, the LaTeX file
will be automatically completed into the following:

%% LaTeX sample file
\documentclass{paper}
\usepackage{hyperref}
\begin{document}
See
\href{http://www.fulviofrisone.com/attachments/article/480/Ballentine%20L.%20Quantum%20mechanics%20-%20a%20modern%20development%20(1998)(T)(673s).pdf}{page
  % 98}

\end{document}
%% LaTeX sample file ends here

As you can see, the auto-completed typesetting result is wrong due to
the leading `%' before ` 98}'.

Any hints for this problem?

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



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

* Re: A strange auto typesetting problem when using auctex.
  2021-06-14  3:45 A strange auto typesetting problem when using auctex Hongyi Zhao
@ 2021-06-14  6:12 ` Hongyi Zhao
  2021-06-14 11:48 ` Tassilo Horn
  2021-06-14 20:04 ` Arash Esbati
  2 siblings, 0 replies; 8+ messages in thread
From: Hongyi Zhao @ 2021-06-14  6:12 UTC (permalink / raw)
  To: auctex-devel; +Cc: help-gnu-emacs

On Mon, Jun 14, 2021 at 11:45 AM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Ubuntu 20.04, I use the latest git master Emacs version compiled by
> myself. I install and load auctex's git master version with the
> following bootstrap code in `~/.emacs.d/init.el':
>
> ;;Bootstrap auctex via straight
> (straight-use-package
>  `( auctex :type git :host nil :repo
> "https://git.savannah.gnu.org/git/auctex.git"
>     :pre-build ,(pcase system-type
>                 (`berkeley-unix '("gmake"))
>                 (_ '(
>                     ;("bash" "-c" "cd ~/.emacs.d/straight/repos/auctex")
>                     ("./autogen.sh")
>                     ("./configure")
>                     ("make")
>                     ("sudo" "make" "install"))))))
>
> (load "auctex.el" nil t t)
> (load "preview-latex.el" nil t t)
> ;;; auctex config ends here
>
> Then I try to test auctex with the following LaTeX sample file:
>
> %% LaTeX sample file
> \documentclass{paper}
> \usepackage{hyperref}
> \begin{document}
> See
> \href{http://www.fulviofrisone.com/attachments/article/480/Ballentine%20L.%20Quantum%20mechanics%20-%20a%20modern%20development%20(1998)(T)(673s).pdf}{page
> 98}
> \end{document}
> %% LaTeX sample file ends here
>
> When I put the point after the `{page 98}' and hit RET, the LaTeX file
> will be automatically completed into the following:
>
> %% LaTeX sample file
> \documentclass{paper}
> \usepackage{hyperref}
> \begin{document}
> See
> \href{http://www.fulviofrisone.com/attachments/article/480/Ballentine%20L.%20Quantum%20mechanics%20-%20a%20modern%20development%20(1998)(T)(673s).pdf}{page
>   % 98}
>
> \end{document}
> %% LaTeX sample file ends here
>
> As you can see, the auto-completed typesetting result is wrong due to
> the leading `%' before ` 98}'.
>
> Any hints for this problem?

Finally, I found the problem was caused by the '%' character appearing
in the URL, which in its literal form, is a comment character of
LaTeX, so the Emacs/auctex thinks that the newline should be commented
out continuously.

Change the URL line into the following will fix the problem:

\href{http://www.fulviofrisone.com/attachments/article/480/Ballentine\%20L.\%20Quantum\%20mechanics\%20-\%20a\%20modern\%20development\%20(1998)(T)(673s).pdf}{page
98}

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



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

* Re: A strange auto typesetting problem when using auctex.
  2021-06-14  3:45 A strange auto typesetting problem when using auctex Hongyi Zhao
  2021-06-14  6:12 ` Hongyi Zhao
@ 2021-06-14 11:48 ` Tassilo Horn
  2021-06-14 15:43   ` Hongyi Zhao
  2021-06-14 20:04 ` Arash Esbati
  2 siblings, 1 reply; 8+ messages in thread
From: Tassilo Horn @ 2021-06-14 11:48 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: auctex-devel, help-gnu-emacs

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> Then I try to test auctex with the following LaTeX sample file:
>
> %% LaTeX sample file
> \documentclass{paper}
> \usepackage{hyperref}
> \begin{document}
> See
> \href{http://www.fulviofrisone.com/attachments/article/480/Ballentine%20L.%20Quantum%20mechanics%20-%20a%20modern%20development%20(1998)(T)(673s).pdf}{page
> 98}
> \end{document}
> %% LaTeX sample file ends here
>
> When I put the point after the `{page 98}' and hit RET, the LaTeX file
> will be automatically completed into the following:

RET doesn't suffice for me but when I fill that paragraph, I get the
same symptom.

> Any hints for this problem?

That's because the URL contains % and therefore looks like a "code
comment" to auctex, e.g.

  \some\latex{code}% And some comment bla bla bla bla...

which would be properly filled as

  \some\latex{code}% And some comment bla bla bla
                   % ...bla...

Of course, here it is wrong.

I don't see what we could do here, unfortunately.  But please file a bug
report (M-x TeX-submit-bug-report RET).

Bye,
Tassilo



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

* Re: A strange auto typesetting problem when using auctex.
  2021-06-14 11:48 ` Tassilo Horn
@ 2021-06-14 15:43   ` Hongyi Zhao
  2021-06-14 19:14     ` Tassilo Horn
  0 siblings, 1 reply; 8+ messages in thread
From: Hongyi Zhao @ 2021-06-14 15:43 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: auctex-devel, help-gnu-emacs

On Mon, Jun 14, 2021 at 8:05 PM Tassilo Horn <tsdh@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > Then I try to test auctex with the following LaTeX sample file:
> >
> > %% LaTeX sample file
> > \documentclass{paper}
> > \usepackage{hyperref}
> > \begin{document}
> > See
> > \href{http://www.fulviofrisone.com/attachments/article/480/Ballentine%20L.%20Quantum%20mechanics%20-%20a%20modern%20development%20(1998)(T)(673s).pdf}{page
> > 98}
> > \end{document}
> > %% LaTeX sample file ends here
> >
> > When I put the point after the `{page 98}' and hit RET, the LaTeX file
> > will be automatically completed into the following:
>
> RET doesn't suffice for me but when I fill that paragraph, I get the
> same symptom.
>
> > Any hints for this problem?
>
> That's because the URL contains % and therefore looks like a "code
> comment" to auctex, e.g.
>
>   \some\latex{code}% And some comment bla bla bla bla...
>
> which would be properly filled as
>
>   \some\latex{code}% And some comment bla bla bla
>                    % ...bla...
>
> Of course, here it is wrong.
>
> I don't see what we could do here, unfortunately.  But please file a bug
> report (M-x TeX-submit-bug-report RET).

Where will this submit the bug report?

But now, very strange, the problem disappeared.

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



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

* Re: A strange auto typesetting problem when using auctex.
  2021-06-14 15:43   ` Hongyi Zhao
@ 2021-06-14 19:14     ` Tassilo Horn
  2021-06-15  0:48       ` Hongyi Zhao
  0 siblings, 1 reply; 8+ messages in thread
From: Tassilo Horn @ 2021-06-14 19:14 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: auctex-devel, help-gnu-emacs

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

>> That's because the URL contains % and therefore looks like a "code
>> comment" to auctex, e.g.
>>
>>   \some\latex{code}% And some comment bla bla bla bla...
>>
>> which would be properly filled as
>>
>>   \some\latex{code}% And some comment bla bla bla
>>                    % ...bla...
>>
>> Of course, here it is wrong.
>>
>> I don't see what we could do here, unfortunately.  But please file a bug
>> report (M-x TeX-submit-bug-report RET).
>
> Where will this submit the bug report?

To the GNU bug tracker, debbugs.gnu.org, assigned to the package auctex.

> But now, very strange, the problem disappeared.

Me neither. :-)

The reason is that once the auto-parser has kicked in and seen that you
are using the hyperref LaTeX package, it'll recognize the \href macro
(which is now also fontified correctly, e.g., not with
font-lock-comment-face including and after the first %) and know that
the % in the URL are not starting a comment.

To demonstrate: When you comment the \usepackage{hyperref} and hit `C-c
C-n' the problem will be back.  Uncommenting it again then and hitting
`C-c C-n' makes it disappear.

Bye the way, you might want to add

    (setq TeX-parse-self t)
    (setq TeX-auto-save t)

to your auctex config as described in (info "(auctex) Top").

Bye,
Tassilo



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

* Re: A strange auto typesetting problem when using auctex.
  2021-06-14  3:45 A strange auto typesetting problem when using auctex Hongyi Zhao
  2021-06-14  6:12 ` Hongyi Zhao
  2021-06-14 11:48 ` Tassilo Horn
@ 2021-06-14 20:04 ` Arash Esbati
  2021-06-15  0:51   ` Hongyi Zhao
  2 siblings, 1 reply; 8+ messages in thread
From: Arash Esbati @ 2021-06-14 20:04 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: auctex-devel, help-gnu-emacs

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> Then I try to test auctex with the following LaTeX sample file:
>
> %% LaTeX sample file
> \documentclass{paper}
> \usepackage{hyperref}
> \begin{document}
> See
> \href{http://www.fulviofrisone.com/attachments/article/480/Ballentine%20L.%20Quantum%20mechanics%20-%20a%20modern%20development%20(1998)(T)(673s).pdf}{page
> 98}
> \end{document}
> %% LaTeX sample file ends here
>
> When I put the point after the `{page 98}' and hit RET, the LaTeX file
> will be automatically completed into the following:
>
> %% LaTeX sample file
> \documentclass{paper}
> \usepackage{hyperref}
> \begin{document}
> See
> \href{http://www.fulviofrisone.com/attachments/article/480/Ballentine%20L.%20Quantum%20mechanics%20-%20a%20modern%20development%20(1998)(T)(673s).pdf}{page
>   % 98}
>
> \end{document}
> %% LaTeX sample file ends here
>
> As you can see, the auto-completed typesetting result is wrong due to
> the leading `%' before ` 98}'.

I can't reproduce what you describe.

Besides that, my simple approach would be to replace %20 with 'space' in
your file, i.e.:

    \href{http://www.fulviofrisone.com/attachments/article/480/Ballentine
      L. Quantum mechanics - a modern development
      (1998)(T)(673s).pdf}{page 98}

This gives AUCTeX enough possibilties for better filling and the link
should also work in your pdf viewer.

Best, Arash



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

* Re: A strange auto typesetting problem when using auctex.
  2021-06-14 19:14     ` Tassilo Horn
@ 2021-06-15  0:48       ` Hongyi Zhao
  0 siblings, 0 replies; 8+ messages in thread
From: Hongyi Zhao @ 2021-06-15  0:48 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: auctex-devel, help-gnu-emacs

On Tue, Jun 15, 2021 at 3:35 AM Tassilo Horn <tsdh@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> >> That's because the URL contains % and therefore looks like a "code
> >> comment" to auctex, e.g.
> >>
> >>   \some\latex{code}% And some comment bla bla bla bla...
> >>
> >> which would be properly filled as
> >>
> >>   \some\latex{code}% And some comment bla bla bla
> >>                    % ...bla...
> >>
> >> Of course, here it is wrong.
> >>
> >> I don't see what we could do here, unfortunately.  But please file a bug
> >> report (M-x TeX-submit-bug-report RET).
> >
> > Where will this submit the bug report?
>
> To the GNU bug tracker, debbugs.gnu.org, assigned to the package auctex.
>
> > But now, very strange, the problem disappeared.
>
> Me neither. :-)
>
> The reason is that once the auto-parser has kicked in and seen that you
> are using the hyperref LaTeX package, it'll recognize the \href macro
> (which is now also fontified correctly, e.g., not with
> font-lock-comment-face including and after the first %) and know that
> the % in the URL are not starting a comment.
>
> To demonstrate: When you comment the \usepackage{hyperref} and hit `C-c
> C-n' the problem will be back.  Uncommenting it again then and hitting
> `C-c C-n' makes it disappear.

Thank you for your insightful analysis.

>
> Bye the way, you might want to add
>
>     (setq TeX-parse-self t)
>     (setq TeX-auto-save t)

So far, I am using the following settings:

(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)


>
> to your auctex config as described in (info "(auctex) Top").
>
> Bye,
> Tassilo

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



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

* Re: A strange auto typesetting problem when using auctex.
  2021-06-14 20:04 ` Arash Esbati
@ 2021-06-15  0:51   ` Hongyi Zhao
  0 siblings, 0 replies; 8+ messages in thread
From: Hongyi Zhao @ 2021-06-15  0:51 UTC (permalink / raw)
  To: Arash Esbati; +Cc: auctex-devel, help-gnu-emacs

On Tue, Jun 15, 2021 at 4:11 AM Arash Esbati <arash@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > Then I try to test auctex with the following LaTeX sample file:
> >
> > %% LaTeX sample file
> > \documentclass{paper}
> > \usepackage{hyperref}
> > \begin{document}
> > See
> > \href{http://www.fulviofrisone.com/attachments/article/480/Ballentine%20L.%20Quantum%20mechanics%20-%20a%20modern%20development%20(1998)(T)(673s).pdf}{page
> > 98}
> > \end{document}
> > %% LaTeX sample file ends here
> >
> > When I put the point after the `{page 98}' and hit RET, the LaTeX file
> > will be automatically completed into the following:
> >
> > %% LaTeX sample file
> > \documentclass{paper}
> > \usepackage{hyperref}
> > \begin{document}
> > See
> > \href{http://www.fulviofrisone.com/attachments/article/480/Ballentine%20L.%20Quantum%20mechanics%20-%20a%20modern%20development%20(1998)(T)(673s).pdf}{page
> >   % 98}
> >
> > \end{document}
> > %% LaTeX sample file ends here
> >
> > As you can see, the auto-completed typesetting result is wrong due to
> > the leading `%' before ` 98}'.
>
> I can't reproduce what you describe.

See the analysis by Tassilo.

>
> Besides that, my simple approach would be to replace %20 with 'space' in
> your file, i.e.:
>
>     \href{http://www.fulviofrisone.com/attachments/article/480/Ballentine
>       L. Quantum mechanics - a modern development
>       (1998)(T)(673s).pdf}{page 98}
>
> This gives AUCTeX enough possibilties for better filling and the link
> should also work in your pdf viewer.

I don't think this is good manner for dealing with URL, as in such
way, it will not be recognized by other applications, so the direct
click and open will be unavailable.

>
> Best, Arash



-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



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

end of thread, other threads:[~2021-06-15  0:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-14  3:45 A strange auto typesetting problem when using auctex Hongyi Zhao
2021-06-14  6:12 ` Hongyi Zhao
2021-06-14 11:48 ` Tassilo Horn
2021-06-14 15:43   ` Hongyi Zhao
2021-06-14 19:14     ` Tassilo Horn
2021-06-15  0:48       ` Hongyi Zhao
2021-06-14 20:04 ` Arash Esbati
2021-06-15  0:51   ` Hongyi Zhao

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