Re: The auto-completion behavior of parenthesis.

2023-07-28 Thread Hongyi Zhao
On Sat, Jul 29, 2023 at 11:53 AM Ikumi Keita  wrote:
>
> Hi Hongyi,
>
> > Hongyi Zhao  writes:
> > On Sat, Jul 29, 2023 at 12:03 AM Ikumi Keita  wrote:
> >>
> >> > Hongyi Zhao  writes:
> >> > I see, due to auctex has already been installed, I must test it as 
> >> > follows:
> >>
> >> > emacs -Q
> >> > M-x package-reinstall RET auctex RET
> >>
> >> > Open a tex file, and `M-: (setq LaTeX-electric-left-right-brace t) RET'
> >>
> >> > Then test the problem discussed here.
> >>
> >> > See the attached screenshot for the results.
> >>
> >> What's wrong? It seems to me that it works as you expected. The round
> >> parens appear in pair in the screenshot.
>
> > You've said:
>
> > Is that buffer in AUCTeX latex mode? I suspect that it's in emacs
> > built-in latex mode due to '-Q' option.
>
>
> > But I've confirmed that the buffer is really in AUCTeX latex mode, as
> > indicated by the AUCTeX menu bars and the following info given by `C-h
> > v major-mode RET`:
>
> Sorry, I still don't see your points. If I understand correctly,
> 1. Previously, "emacs -Q" session resulted in built-in latex mode and
>`LaTeX-electric-left-right-brace' wasn't effective. You typed "(" but
>emacs didn't complete it to "()".
> 2. Now you have enabled AUCTeX latex mode even in "emacs -Q" session and
>AUCTeX responds to `LaTeX-electric-left-right-brace'. You typed "("
>and got "()" as expected.
> Then what's wrong?

Let me comments and explains step-by-step:

1. You said:

"emacs -Q" session resulted in built-in latex mode

Yes. This is true in all my testings.

After the above step 1, I observed the following behavior:

2. If AUCTeX hasn't installed by `package-install', after I installed
it by `package-install' and open a .tex file, then AUCTeX LaTeX mode
will be enabled automatically.

3. If AUCTeX has already installed by `package-install', after I
re-installed it by `package-reinstall' and open a .tex file, then
*still* AUCTeX LaTeX mode will be enabled automatically.

4. If AUCTeX has already installed by `package-install', and I open a
.tex file immediately without reinstall AUCTeX, then AUCTeX LaTeX mode
will *not* be enabled automatically and the built-in latex mode still
will be effective for the opened tex buffer.


This is why it is necessary to test it using the following commands to
ensure that the latest version of AUCTeX is freshly installed for the
current Emacs session initiated by `emacs -Q'.

M-x package-refresh-contents RET
M-x package-reinstall RET auctex RET

> Regards,
> Ikumi Keita
> #StandWithUkraine #StopWarInUkraine

Best,
Zhao



Re: The auto-completion behavior of parenthesis.

2023-07-28 Thread Ikumi Keita
Hi Hongyi,

> Hongyi Zhao  writes:
> On Sat, Jul 29, 2023 at 12:03 AM Ikumi Keita  wrote:
>> 
>> > Hongyi Zhao  writes:
>> > I see, due to auctex has already been installed, I must test it as follows:
>> 
>> > emacs -Q
>> > M-x package-reinstall RET auctex RET
>> 
>> > Open a tex file, and `M-: (setq LaTeX-electric-left-right-brace t) RET'
>> 
>> > Then test the problem discussed here.
>> 
>> > See the attached screenshot for the results.
>> 
>> What's wrong? It seems to me that it works as you expected. The round
>> parens appear in pair in the screenshot.

> You've said:

> Is that buffer in AUCTeX latex mode? I suspect that it's in emacs
> built-in latex mode due to '-Q' option.


> But I've confirmed that the buffer is really in AUCTeX latex mode, as
> indicated by the AUCTeX menu bars and the following info given by `C-h
> v major-mode RET`:

Sorry, I still don't see your points. If I understand correctly,
1. Previously, "emacs -Q" session resulted in built-in latex mode and
   `LaTeX-electric-left-right-brace' wasn't effective. You typed "(" but
   emacs didn't complete it to "()".
2. Now you have enabled AUCTeX latex mode even in "emacs -Q" session and
   AUCTeX responds to `LaTeX-electric-left-right-brace'. You typed "("
   and got "()" as expected.
Then what's wrong?

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine



Re: The auto-completion behavior of parenthesis.

2023-07-28 Thread Hongyi Zhao
On Sat, Jul 29, 2023 at 12:03 AM Ikumi Keita  wrote:
>
> > Hongyi Zhao  writes:
> > I see, due to auctex has already been installed, I must test it as follows:
>
> > emacs -Q
> > M-x package-reinstall RET auctex RET
>
> > Open a tex file, and `M-: (setq LaTeX-electric-left-right-brace t) RET'
>
> > Then test the problem discussed here.
>
> > See the attached screenshot for the results.
>
> What's wrong? It seems to me that it works as you expected. The round
> parens appear in pair in the screenshot.

You've said:

Is that buffer in AUCTeX latex mode? I suspect that it's in emacs
built-in latex mode due to '-Q' option.


But I've confirmed that the buffer is really in AUCTeX latex mode, as
indicated by the AUCTeX menu bars and the following info given by `C-h
v major-mode RET`:

latex-mode is an autoloaded interactive byte-compiled Lisp function in
‘tex-mode.el’.

(latex-mode)

This function has :override advice: ‘TeX-latex-mode’.

This is an :override advice, which means that ‘latex-mode’ isn’t
run at all, and the documentation below may be irrelevant.

;;; Hit on ‘TeX-latex-mode’, I'll see the following:

TeX-latex-mode is an autoloaded interactive byte-compiled Lisp
function in ‘latex.el’.

(TeX-latex-mode)

Major mode in AUCTeX for editing LaTeX files.
See info under AUCTeX for full documentation.

> Regards,
> Ikumi Keita
> #StandWithUkraine #StopWarInUkraine

Best,
Zhao



bug#64921: 13.2.1; Infinite loop in LaTeX-arg-biblatex-cites with RefTeX

2023-07-28 Thread Gustavo Barros
Hi All,

I might be missing something obvious on this one, but I couldn't
figure out a way to do it and as far as I understand the code, I see
no way to break the loop in `LaTeX-arg-biblatex-cites'.  So I report.

When RefTeX is plugged into AUCTeX, trying to insert a `biblatex'
citation list with `TeX-insert-macro' will call
`LaTeX-arg-biblatex-cites' and, as far as I can tell, there is no way
to tell that function no further arguments are required.  For sure,
one can interrupt the cycle from the call to `reftex-citation' with
"C-g" or "q", but then one also loses the citation altogether making
the attempt futile.

To reproduce starting with `emacs -Q'.  Some setup:

#+begin_src emacs-lisp
(add-to-list 'load-path "~/.emacs.d/elpa/auctex-13.2.1")
(load "auctex.el" nil t t)
(load "reftex.el" nil t t)
(setq TeX-parse-self t)
(setq TeX-auto-save t)
(setq reftex-plug-into-AUCTeX t)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-use-external-file-finders t)
#+end_src

Visit a file with contents:

#+begin_src latex
\documentclass{article}

\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}

\end{document}
#+end_src

Now, use `TeX-insert-macro' to insert a biblatex qualified citation
list, say `\cites': "C-c RET cites RET".  You are prompted for a
regexp, as usual, you can enter it, get a list of results, select one
with RET.  And, you are prompted again for a new regexp, you can enter
it and select a new candidate, etc. etc.  The only chance you get to
break the loop is at the regexp prompt, where you can leave it with
"C-g" or "q", but then you lose the whole citation command, which is
deleted.

Indeed, the loop in `LaTeX-arg-biblatex-cites' takes the form:

#+begin_src emacs-lisp
(while items
  ;; ... handling of optional arguments
  (setq items (if (and (fboundp 'reftex-citation)
   (fboundp 'reftex-plug-flag)
   (reftex-plug-flag 3))
  ;; Use RefTeX when enabled.
  (reftex-citation t)
;; Multiple citation keys in each argument are allowed.
(TeX-completing-read-multiple
 (TeX-argument-prompt optional prompt "Key(s)")
 (LaTeX-bibitem-list
  ;; ... macro/argument is inserted, but value of `items' is left untouched
  )
#+end_src

So, since `items' is not touched after it is set with
`(reftex-citation t)', leaving the loop would require a way for
`reftex-citation's UI to return nil.  I don't see how.  But, again, I
may be missing something...

Best regards,
Gustavo.



Emacs  : GNU Emacs 29.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0)
 of 2023-07-23
Package: 13.2.1

current state:
==
(setq
 AUCTeX-date "2023-07-20"
 window-system 'x
 LaTeX-version "2e"
 TeX-style-path '("~/.emacs.d/auctex"
"/home/gustavo/.emacs.d/elpa/auctex-13.2.1/style"
  "/home/gustavo/.emacs.d/auctex/auto"
"/home/gustavo/.emacs.d/auctex/style" "auto" "style")
 TeX-auto-save t
 TeX-parse-self t
 TeX-master t
 TeX-command-list '(("TeX" "%(PDF)%(tex) %(file-line-error)
%`%(extraopts) %S%(PDFout)%(mode)%' %(output-dir) %t"
 TeX-run-TeX nil (plain-tex-mode ams-tex-mode
texinfo-mode) :help "Run plain TeX")
("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil (latex-mode
doctex-mode) :help "Run LaTeX")
("Makeinfo" "makeinfo %(extraopts) %(o-dir) %t"
TeX-run-compile nil (texinfo-mode) :help
 "Run Makeinfo with Info output")
("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html
%t" TeX-run-compile nil (texinfo-mode)
 :help "Run Makeinfo with HTML output")
("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%'
%(output-dir) %t" TeX-run-TeX nil
 (ams-tex-mode) :help "Run AMSTeX")
("ConTeXt" "%(cntxcom) --once --texutil %(extraopts)
%(execopts)%t" TeX-run-TeX nil
 (context-mode) :help "Run ConTeXt once")
("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t"
TeX-run-TeX nil (context-mode) :help
 "Run ConTeXt until completion")
("BibTeX" "bibtex %(O?aux)" TeX-run-BibTeX nil
 (plain-tex-mode latex-mode doctex-mode ams-tex-mode
texinfo-mode context-mode) :help
 "Run BibTeX")
("Biber" "biber %(output-dir) %s" TeX-run-Biber nil
 (plain-tex-mode latex-mode doctex-mode ams-tex-mode
texinfo-mode) :help "Run Biber")
("Texindex" "texindex %s.??" TeX-run-command nil
(texinfo-mode) :help "Run Texindex")
("Texi2dvi" "%(PDF)texi2dvi %t" TeX-run-command nil
(texinfo-mode) :help
 "Run Texi2dvi or Texi2pdf")
("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer")
("Print" "%p" TeX-run-command t t :help "Print the file")
("Queue" "%q" TeX-run-background nil t :help "View the
printer queue" :visible
 TeX-queue-command)
("File" "%(o?)dvips %d -o %f " 

Re: The auto-completion behavior of parenthesis.

2023-07-28 Thread Ikumi Keita
> Hongyi Zhao  writes:
> I see, due to auctex has already been installed, I must test it as follows:

> emacs -Q
> M-x package-reinstall RET auctex RET

> Open a tex file, and `M-: (setq LaTeX-electric-left-right-brace t) RET'

> Then test the problem discussed here.

> See the attached screenshot for the results.

What's wrong? It seems to me that it works as you expected. The round
parens appear in pair in the screenshot.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine



Re: The auto-completion behavior of parenthesis.

2023-07-28 Thread Hongyi Zhao
On Fri, Jul 28, 2023 at 2:43 PM Ikumi Keita  wrote:
>
> Hi,
>
> > Hongyi Zhao  writes:
> > After starting with 'emacs -Q', I tried to do the above test with the
> > guidance here [1] to install auctex:
>
> > M-x package-install RET auctex RET
>
> > But I meet the following:
>
> > Install package: auctex RET
>
> > no match
>
> I think that your local elpa database wasn't updated when you tried it
> and emacs tries to install older version of AUCTeX, which no longer
> existed on the elpa server.
>
> >> Hongyi Zhao  writes:
>
> > Any then, I use a minimal tex file:
>
> > \documentclass{article}
> > \begin{document}
> > Hello world.
> > \end{document}
>
> > After opening the above file, eval the following setting:
>
> > M-: (setq LaTeX-electric-left-right-brace t) RET
>
> > Then, I observed the same effect as shown be you.
>
> Is that buffer in AUCTeX latex mode? I suspect that it's in emacs
> built-in latex mode due to '-Q' option.

`C-h v major-mode RET' gives the following:

--- begin buffer ---
major-mode is a variable defined in ‘C source code’.

Its value is ‘latex-mode’
Original value was ‘fundamental-mode’
Local in buffer test.tex; global value is fundamental-mode

Symbol for current buffer’s major mode.
The default value (normally ‘fundamental-mode’) affects new buffers.
A value of nil means to use the current buffer’s major mode, provided
it is not marked as "special".

  Automatically becomes buffer-local when set.
  You can customize this variable.
  Probably introduced at or before Emacs version 29.1.

[back]
--- end buffer ---

See the attached screenshot for more details.

> Regards,
> Ikumi Keita
> #StandWithUkraine #StopWarInUkraine

Best,
Zhao


Re: The auto-completion behavior of parenthesis.

2023-07-28 Thread Hongyi Zhao
On Fri, Jul 28, 2023 at 3:43 PM Hongyi Zhao  wrote:
>
> On Fri, Jul 28, 2023 at 2:43 PM Ikumi Keita  wrote:
> >
> > Hi,
> >
> > > Hongyi Zhao  writes:
> > > After starting with 'emacs -Q', I tried to do the above test with the
> > > guidance here [1] to install auctex:
> >
> > > M-x package-install RET auctex RET
> >
> > > But I meet the following:
> >
> > > Install package: auctex RET
> >
> > > no match
> >
> > I think that your local elpa database wasn't updated when you tried it
> > and emacs tries to install older version of AUCTeX, which no longer
> > existed on the elpa server.
>
> I tried with `M-x package-refresh-contents' but still meet the same problem.
>
> And I also tried with `M-x package-list-packages` and find that auctex
> already installed as shown in the attachment.
>
> > >> Hongyi Zhao  writes:
> >
> > > Any then, I use a minimal tex file:
> >
> > > \documentclass{article}
> > > \begin{document}
> > > Hello world.
> > > \end{document}
> >
> > > After opening the above file, eval the following setting:
> >
> > > M-: (setq LaTeX-electric-left-right-brace t) RET
> >
> > > Then, I observed the same effect as shown be you.
> >
> > Is that buffer in AUCTeX latex mode? I suspect that it's in emacs
> > built-in latex mode due to '-Q' option.
>
> See the attached screenshot. But this time, all test fails.

I see, due to auctex has already been installed, I must test it as follows:

emacs -Q
M-x package-reinstall RET auctex RET

Open a tex file, and `M-: (setq LaTeX-electric-left-right-brace t) RET'

Then test the problem discussed here.

See the attached screenshot for the results.

> > Regards,
> > Ikumi Keita
> > #StandWithUkraine #StopWarInUkraine
>
> Best,
> Zhao


Re: The auto-completion behavior of parenthesis.

2023-07-28 Thread Ikumi Keita
Hi,

> Hongyi Zhao  writes:
> After starting with 'emacs -Q', I tried to do the above test with the
> guidance here [1] to install auctex:

> M-x package-install RET auctex RET

> But I meet the following:

> Install package: auctex RET

> no match

I think that your local elpa database wasn't updated when you tried it
and emacs tries to install older version of AUCTeX, which no longer
existed on the elpa server.

>> Hongyi Zhao  writes:

> Any then, I use a minimal tex file:

> \documentclass{article}
> \begin{document}
> Hello world.
> \end{document}

> After opening the above file, eval the following setting:

> M-: (setq LaTeX-electric-left-right-brace t) RET

> Then, I observed the same effect as shown be you.

Is that buffer in AUCTeX latex mode? I suspect that it's in emacs
built-in latex mode due to '-Q' option.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine