Re: [can't compile the main branch]

2024-04-25 Thread Stefan Monnier
> And I like the way the manual is formatted.  Compare this:
> https://www.gnu.org/software/auctex/manual/auctex.html
> with this:
> https://elpa.gnu.org/devel/doc/auctex.html

Hmm... nice.  FWIW, the elpa rendering is the same as that of

https://www.gnu.org/software/emacs/manual/html_node/emacs/index.html

not sure why https://www.gnu.org/software/auctex/manual/auctex.html is
not as nice.

While I'm here, I think with the new setup we can get rid of
`Makefile.in` and `auctex.el.in`.


Stefan




Re: [can't compile the main branch]

2024-04-25 Thread Stefan Monnier
> And there it is!  So it seems to work now; you can stop knocking. ;-)

Yay!  That wood should is happy,


Stefan




Re: [can't compile the main branch]

2024-04-24 Thread Stefan Monnier
> AFAIU, using `update-file-autoloads' again means keeping track of all
> AUCTeX files in the new GNUmakefile, or is there a better solution?

You should be able to use `update-directory-autoloads`.
It's a bit more cumbersome to use than `loaddefs-generate` but other
than that it should be OK.


Stefan




Re: [can't compile the main branch]

2024-04-24 Thread Stefan Monnier
> gitlog-to-auctexlog is based on gitlog-to-emacslog.  Should the issue be
> reported there as well?  gitlog-to-emacslog isn't different in this
> regard:
> https://git.savannah.gnu.org/cgit/emacs.git/tree/build-aux/gitlog-to-emacslog#n62

`gitlog-to-emacslog` is used only to build the release tarballs, not
during a normal build, so it's OK for it to fail when Git fails, and
it's not OK for it to generate an empty ChangeLog.

Which points out that maybe instead of changing `gitlog-to-auctexlog`
it'd be easier to change the `make` rule so it doesn't build
`ChangeLog` (and have another rule that does build `ChangeLog` for
those cases where it's important).


Stefan




Re: [can't compile the main branch]

2024-04-24 Thread Stefan Monnier
> But before investing time on Uwe's scenario: Stefan, do you know why
> no new devel release has been built so far?

You've presumably received copies (via auctex-devel) of the build
error notification.  The original problem was that elpa.gnu.org did not
have TeX installed.  After fixing it there was another problem of access
rights when running TeX.
I believe it is now fixed and it should get built within the next
6 hours.  Knocking on wood.  


Stefan




Re: [can't compile the main branch]

2024-04-24 Thread Stefan Monnier
> +# If this is not a Git repository, just generate an empty ChangeLog.
> +test -d .git || {
> +  >"$output"
> +  exit
> +}
> +
>  # Get the new value for gen_origin from the latest version in the repository.
>  new_origin=`git log --pretty=format:%H 'HEAD^!'` || exit

I suspect it would be better to merge those two (i.e. instead of
testing for the presence of `.git` just use `git log`s failure as the
test).


Stefan




Re: [can't compile the main branch]

2024-04-24 Thread Stefan Monnier
> Hence either
> 1) Uwe installs git

He does have Git installed.  He's just working in a directory that's not
under Git's control.

> 2) AUCTeX implements fallback in build-aux/gitlog-to-auctexlog
> is necessary to have Changelog.

IMO `build-aux/gitlog-to-auctexlog` should gracefully fail
(e.g. generate an empty file, or put the Git error into that
file).


Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-23 Thread Stefan Monnier
>> I use it with `emacs -Q ...` when I want to try and isolate a problem.
>
> Thanks for the hint.  My approach to that for package `foo' until now
> was:
>
> (progn
>   (package-initialize t)
>   (package-activate 'foo))

That works as well, indeed.  There are many ways to skin this cat.  
[ In my case, most packages are installed in a non-standard directory,
  so I'd first have to set `package-user-dir`, and also I find it
  less convenient to use `--eval` than `-l`.  ]

> By ugly I meant (load "loaddefs.el").

Ah, OK.  Not sure why you find it ugly, but there's no accounting
for taste.

>   • Get auctex-autoloads.el instead of loaddefs.el, and

I think this is just a matter of changing the file name
in GNUmakefile's `autoloads` target.

>   • Put the addition to `load-path' in that file, so the forms above
> turn into (load "~/Repos/el/auctex/auctex-autoloads" nil t t) as
> well?

I think the patch below does that.


Stefan
diff --git a/GNUmakefile b/GNUmakefile
index b5cec4822e..fbf653ab09 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -17,7 +17,8 @@
 #   latex: prtightpage.def
 #   latex: prtracingall.def
 
-EMACS=emacs --batch -q -no-site-file -no-init-file -l lpath.el
+EMACSBIN=emacs
+EMACS=$(EMACSBIN) --batch -q -no-site-file -no-init-file -l lpath.el
 MAKEINFO=makeinfo
 INSTALL_INFO=install-info
 PERL=perl
@@ -44,7 +45,11 @@ all: $(ALL_GENERATED_FILES) compile autoloads
 compile: $(patsubst %.el,%.elc,$(wildcard *.el style/*.el))
 
 autoloads:
-	$(EMACS) -f loaddefs-generate-batch loaddefs.el .
+	$(EMACS) --eval \
+  "(loaddefs-generate \".\" \"auctex-autoloads.el\" \
+nil \"(add-to-list 'load-path 	  	\
+   (directory-file-name \
+(file-name-directory load-file-name)))\")"
 
 %.elc: %.el
 	$(EMACS) -f batch-byte-compile $<
@@ -74,18 +79,16 @@ README: doc/intro.texi doc/preview-readme.texi doc/macros.texi
 # Commands copied from autogen.sh and doc/Makefile.in.
 IGNORED:=$(shell rm -f ChangeLog && ./build-aux/gitlog-to-auctexlog && cat ChangeLog.1 >> ChangeLog)
 # Committer date of HEAD.
-AUCTEXDATE:=$(shell git log -n1 --pretty=tformat:"%ci" \
-	| sed -nre 's/ /_/p' | sed -nre 's/ .*//p')
+AUCTEXDATE:=$(shell (git log -n1 --pretty=tformat:"%ci" 2>/dev/null \
+ || date +"%Y-%m-%d %T") 		   	\
+| sed -re 's/ /_/' -e 's/ .*//')
 # Extract the version number from the diff line "+;; Version: 14.0.4" of
 # the commit HEAD which is only filled when we did a release in the last
 # commit.
-THISVERSION:=$(shell git show HEAD -- auctex.el \
+THISVERSION:=$(shell git show HEAD -- auctex.el 2>/dev/null \
 	| sed -nre 's/[+];; Version: ([0-9]+.[0-9]+.[0-9]+)/\1/p')
-# Extract the last version number from the previous change to auctex.el,
-# i.e., only look at commits starting at HEAD~1.
-LASTVERSION:=$(shell git log HEAD~1 -p --first-parent -- auctex.el \
-	| grep "+;; Version: " \
-	| sed -nre 's/[+];; Version: ([0-9]+.[0-9]+.[0-9]+)/\1/p;q')
+# Extract the last released version number from `auctex.el`.
+LASTVERSION:=$(shell sed -nre '/Version:/{s/;; Version: ([0-9]+.[0-9]+.[0-9]+)/\1/p;q}' auctex.el)
 AUCTEXVERSION:=$(if $(THISVERSION),$(THISVERSION),$(LASTVERSION).$(AUCTEXDATE))
 
 tex-site.el: tex-site.el.in


Re: [can't compile the main branch]

2024-04-23 Thread Stefan Monnier
> fatal: not a git repository (or any of the parent directories): .git
> fatal: not a git repository (or any of the parent directories): .git
> fatal: not a git repository (or any of the parent directories): .git
> fatal: not a git repository (or any of the parent directories): .git
> (cd doc; makeinfo -D rawfile --no-headers intro.texi --output -) >README
> (cd doc; makeinfo -D rawfile --no-headers preview-readme.texi --output -) >> 
> README
> sed -e 's|@lisppackagelispdir@|(file-name-directory load-file-name)|'\
> -e 's|@lisppackagedatadir@|(file-name-directory load-file-name)|'\
> -e 's|@lispautodir@|(if (file-writable-p "/usr/local/var/auctex") 
> "/usr/local/var/auctex" "~/.emacs.d/auctex")|'\
> -e 's|@AUCTEXVERSION@|.|'\
> -e 's|@AUCTEXDATE@||'\
> tex-site.el.in >tex-site.el
> make: *** No rule to make target 'ChangeLog', needed by 'doc/version.texi'.  
> Stop.
>
> Now why on earth should I have a git parent directory or directories?

The GNUmakefile tries to find the date of the commit you're building,
and that's only available from the VCS metadata.  The patch below should
make it fallback to using the current date.

Git's also used to figure out if the current commit is a release.
I defaulted to "not a release" in the patch.

> There is also no configure option more, since I have various emacs
> versions installed (the one Ubuntu ships, the one or two I have compiled
> from master (and which end up in /opt/emacs29 or /opt/emacs30)
> So I have to to edit the makefile manually?

You could use `make ... EMACS=...` but that was rather inconvenient
since the `EMACS=...` arg needed several specific options.  In the patch
below I introduced an `EMACSBIN` var, so you can do

make EMACSBIN=/usr/bin/emacs-34.1

to build with your Emacs-34.1.

> 1. I pull, make (and would to install)
>
> 2. I would like to do some experiments (say starting a new style
>file) but now I am editing files of a repository I also use for
>my daily work. That does sound a bit dangerous.
>
> Can't you leave the make install  option please.

There are many ways to solve this (including using a separate clone or
just a separate worktree, or refreshing the previous `make install`
code, ...) so I'll let others decide what AUCTeX should do about it.

Personally, I've been editing the very files I use for my daily work for
as long as I can remember and find it to be the best option.  


Stefan

diff --git a/GNUmakefile b/GNUmakefile
index b5cec4822e..4fb8829124 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -17,7 +17,8 @@
 #   latex: prtightpage.def
 #   latex: prtracingall.def
 
-EMACS=emacs --batch -q -no-site-file -no-init-file -l lpath.el
+EMACSBIN=emacs
+EMACS=$(EMACSBIN) --batch -q -no-site-file -no-init-file -l lpath.el
 MAKEINFO=makeinfo
 INSTALL_INFO=install-info
 PERL=perl
@@ -74,18 +75,16 @@ README: doc/intro.texi doc/preview-readme.texi doc/macros.texi
 # Commands copied from autogen.sh and doc/Makefile.in.
 IGNORED:=$(shell rm -f ChangeLog && ./build-aux/gitlog-to-auctexlog && cat ChangeLog.1 >> ChangeLog)
 # Committer date of HEAD.
-AUCTEXDATE:=$(shell git log -n1 --pretty=tformat:"%ci" \
-	| sed -nre 's/ /_/p' | sed -nre 's/ .*//p')
+AUCTEXDATE:=$(shell (git log -n1 --pretty=tformat:"%ci" 2>/dev/null \
+ || date +"%Y-%m-%d %T") 		   	\
+| sed -re 's/ /_/' -e 's/ .*//')
 # Extract the version number from the diff line "+;; Version: 14.0.4" of
 # the commit HEAD which is only filled when we did a release in the last
 # commit.
-THISVERSION:=$(shell git show HEAD -- auctex.el \
+THISVERSION:=$(shell git show HEAD -- auctex.el 2>/dev/null \
 	| sed -nre 's/[+];; Version: ([0-9]+.[0-9]+.[0-9]+)/\1/p')
-# Extract the last version number from the previous change to auctex.el,
-# i.e., only look at commits starting at HEAD~1.
-LASTVERSION:=$(shell git log HEAD~1 -p --first-parent -- auctex.el \
-	| grep "+;; Version: " \
-	| sed -nre 's/[+];; Version: ([0-9]+.[0-9]+.[0-9]+)/\1/p;q')
+# Extract the last released version number from `auctex.el`.
+LASTVERSION:=$(shell sed -nre '/Version:/{s/;; Version: ([0-9]+.[0-9]+.[0-9]+)/\1/p;q}' auctex.el)
 AUCTEXVERSION:=$(if $(THISVERSION),$(THISVERSION),$(LASTVERSION).$(AUCTEXDATE))
 
 tex-site.el: tex-site.el.in


Re: Making AUCTeX ELPA releases from the master branch

2024-04-23 Thread Stefan Monnier
>> Side note: an AUCTeX installed with `package.el` behaves very similarly
>> except the autoloads file is called `auctex-autoloads.el` instead of
>> `loaddefs.el` and that this file takes care of the `add-to-list`, so
>> users just need to
>>
>> (load "~/Repos/el/auctex/auctex-autoloads")
>
> Thanks, but in which scenario do users have to use the form above?

I use it with `emacs -Q ...` when I want to try and isolate a problem.

> I thought when AUCTeX is installed via package.el, say with regular
> updates or `package-install-from-archive', `package-initialize' and some
> such would do the job.

Indeed, usually `package-activate(-all)` performs those `load`s for the user.
I was just pointing out that there's a pre-existing and very similar
"convention" and that convention is slightly simpler for the users, so
if it's not too cumbersome it might be worth following that convention
(it's not very important, tho, so it's really up to the maintainers).

> Side question: Is it possible to achieve something similar for the setup
> above, i.e., running AUCTeX directly from the clone?  This looks really
> ugly to me:
>
>   (load "~/Repos/el/auctex/loaddefs.el" nil t t)

Not sure what you mean by "similar" since what you here describe as ugly
is almost identical.  I think I'm misunderstanding something.


Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-23 Thread Stefan Monnier
> I think we need to adapt our instructions.  To run straight from the
> clone, this seems to work fine:
>
> (add-to-list 'load-path "~/Repos/el/auctex")
> (load "~/Repos/el/auctex/loaddefs.el" nil t t)

Side note: an AUCTeX installed with `package.el` behaves very similarly
except the autoloads file is called `auctex-autoloads.el` instead of
`loaddefs.el` and that this file takes care of the `add-to-list`, so
users just need to

(load "~/Repos/el/auctex/auctex-autoloads")


- Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-23 Thread Stefan Monnier
> I was thinking about this too and my vote is to go with option 2 (i.e.,
> not your favorite ;-).  I think it would make sense to have a sort of
> "staging area" where we can install code which might break or have other
> problems.  Syncing it directly to ELPA-DEVEL and letting people install
> it might end in too much trouble for the brave users.

FWIW, while we don't have good statistics to confirm it, I believe that
very few users routinely install packages from GNU-devel: contrary to
Melpa where the system is setup to encourage the use of Melpa over
Melpa-stable, the GNU ELPA archive is setup so as to encourage the use
of GNU ELPA over GNU-devel ELPA.

So, those few users installing from GNU-devel ELPA are probably ready
and willing (if not eager) to try buggy software (that's what GNU-devel is for).
Especially since fixes are also made available more promptly.


Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-23 Thread Stefan Monnier
> Stefan, how would I make the switch on elpa?  The package recipe I've
> tested is this
>
>  (auctex :url "https://git.savannah.gnu.org/git/auctex.git;
>  :branch "main"
>  :news "NEWS.org"
>  :make "elpa"
>  :doc ("doc/auctex.texi" "doc/preview-latex.texi"))
>
> Does pushing the new recipe in elpa-packages suffice?

Yes (tho we use a different indentation (for which there's no
auto-indent rules )).


Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-22 Thread Stefan Monnier
>> Duh: it's `:doc`, not `:manual`!
>> Sorry!
> Haha, and then it works just fine. ;-)

Yay!


Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-22 Thread Stefan Monnier
> Yes, it is.  But I need the distinction if the current version got
> there just now (in HEAD) or previously.

So just a "yes/no" kind of information?  I wonder what you use it for.

>> [ This assumes that the `:manual ...` thingy does
>>   successfully build the docs.  ]
>
> This is where I'm not sure.  At least it doesn't seem to have an effect
> when running "make auctex.tar" locally (as said in my other mail).  The
> tar file only contains the *.info files and the dir file in doc/ which
> are build by running "make all".

Duh: it's `:doc`, not `:manual`!
Sorry!


Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-22 Thread Stefan Monnier
>> Why do you need to look at diffs?
> In order to extract the version number.

I don't understand: it's right there in the file, you don't need
the diffs to extract it, no?

> Does :manual ("doc/auctex.texi" "doc/preview-latex.texi") tell elpa to
> build the docs again although the recipe's :make "all" did already build
> them (but at the "wrong" location)?

Yup (the two know nothing of each other).

> That would be ok for me; I would also be willing to add a special elpa
> make target moving the files or generating another top-level dir file.

You could also replace the "make all" with another target that doesn't
build the docs.
[ This assumes that the `:manual ...` thingy does successfully
  build the docs.  ]

> But I certainly want the additional benefit of having the docs linked.

That happens only if you use `:manual ...`.


Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-21 Thread Stefan Monnier
>> The "%H" above makes it output the commit hash where `Version:` was
>> changed, so you can replace that with an appropriate % thingy to get
>> the date instead.
> Why would I need the date of the last release?

Don't know.  I guess I misundersood what you meant by:

Instead of looking at specially formatted lines in ChangeLog, it just
looks at the git diffs to check when there was a "+;; Version: ..."
change in auctex.el.  ...

Why do you need to look at diffs?

> Oh, no, one thing doesn't: the fine manuals.  I've changed it so that
> they stay in doc/ and there's also the dir file referencing the auctex
> and preview-latex manual.  Do they need to be top-level for elpa (in
> which case I'd just add an elpa make target doing the move) or can I
> somehow make that work?

Indeed, they need to be moved: `package.el` won't see your manual if the
`dir` is not in the top-level directory (and the Info viewer won't
search in subdirs, so either you need the Info files to be at top-level
or you need to change the `dir` file so it refers to `doc/auctex`).

Our tarball build scripts can take care of building the Info files and
the `dir` (and moving them as needed), so maybe you can just add

:manual ("doc/auctex.texi" "doc/preview-latex.texi")

to the spec and that'll do the trick (with the advantage that the
manual will then also be made available at
`elpa.gnu.org/packages/doc/auctex.html`).


Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-20 Thread Stefan Monnier
> Alright, I've had some time to do some fiddling.  In the auctex
> repository, there's some new main branch (based on externals/auctex)
> where I've changed how AUCTEXVERSION and AUCTEXDATE are determined.
> Instead of looking at specially formatted lines in ChangeLog, it just
> looks at the git diffs to check when there was a "+;; Version: ..."
> change in auctex.el.  It seems to work fine when I run "make -f
> GNUMakefile".

FWIW, the `elpa-admin.el` code needs to do something similar and it asks
Git a bit more directly (i.e. with the generating the diff):

   (elpaa--call
(current-buffer)
"git" "log" "-n1" "--oneline" "--no-patch"
"--pretty=format:%H"
(when (elpaa--spec-get pkg-spec :merge)
  ;; Finding "the" revision when there's a merge involved is
  ;; fundamentally unreliable.
  ;; Ideally we should probably signal an error when the commit
  ;; we found is not on all paths from FROM to avoid making an
  ;; arbitrary choice.
  ;; For `:merge'd packages, the commit that flipped `Version:'
  ;; is usually not what we want, since that one was on the
  ;; upstream branch, without our own changes.
  ;; We use `--first-parent' for this reason, so it prefers
  ;; the corresponding merge commit (which is not ideal either
  ;; but is arguably the best we can do in that case).
  "--first-parent")
"-L" (concat "/^;;* *\\(Package-\\)\\?Version:/,+1:"
 (file-name-nondirectory
  (elpaa--main-file pkg-spec)))

The "%H" above makes it output the commit hash where `Version:` was
changed, so you can replace that with an appropriate % thingy to get the
date instead.

> Now I'd like to test building auctex.tar using your recipe.  I've
> checked out that new main branch into ../elpa/packages/auctex/ (or
> actually auctex is a symlink to my auctex clone).  With the current
> elpa-packages recipe
>
>(auctex :url "https://git.savannah.gnu.org/git/auctex.git;
>:news "NEWS.org")
>
> an auctex.tar is built successfully but apparently that didn't run the
> GNUMakefile, for example, tex-site.el isn't included because it's not
> generated from tex-site.el.in.

Indeed, by default we don't run any make or any such thing, we just tar
up the files.

> So I've tried to add :make "all" or even :shell-command "make -g
> GNUMakefile" to the auctex recipe

Sounds good.

> but then I get this error:
>
> --8<---cut here---start->8---
> ❯ make auctex.tar
> emacs --batch -Q -l admin/elpa-admin.el \
> -f elpaa-batch-pkg-spec-make-dependencies .pkg-descs.mk
> emacs --batch -l /home/horn/tmp/elpa/admin/elpa-admin.el\
> -f elpaa-batch-make-one-tarball auctex.tar
>  Building tarball auctex.tar...
> Build error for auctex.tar: (error "Error-indicating exit code in 
> elpaa--call-sandboxed:
> bwrap: Can't bind mount /oldroot/home/horn/Repos/el/auctex on 
> /newroot/home/horn/tmp/elpa/packages/auctex/: Unable to mount source on 
> destination: No such file or directory
> ")
>  Build of package auctex.tar FAILED!!
> --8<---cut here---end--->8---
>
> What does that error try to tell me?

Good question.  I haven't seen this error yet, so I don't know.
Maybe the problem is in the "actually auctex is a symlink to my auctex
clone".

If you want to try and debug this, then edit the `elpa-config` file to
put

(debug t)

in the config, so that you'll get a much more verbose output showing for
example exactly the `bwrap` command executed, which you can then
reproduce "by hand".

But another option is to disregard the problem: presumably you trust
AUCTeX's code, so you don't need to run that make recipe within
a sandbox to confine its misdeeds, and the above error will not appear
on `elpa.gnu.org`.
So, instead of (or in addition to, if you prefer) the above (debug t)
thingy, put:

(sandbox nil)

so the commands are run without Bubblewrap.  


Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-10 Thread Stefan Monnier
>> And nowhere in the elpa repository do I find some statement that for
>> auctex the externals/auctex branch in elpa.git is to be used instead
>> of the main or master branch of auctex.git.
> It's always built from `externals/`.

Well, not for `make auctex.tar` where it's built from whatever is HEAD
in `packages/auctex`.  But in `elpa.gnu.git` HEAD is indeed pointing to
`externals/`.


Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-10 Thread Stefan Monnier
> So I could just replace packages/auctex with some other clone of
> auctex.git?

Yes.

>> So your first and third steps above can happen at some other time.
> Alright.  But I currently don't understand how "make packages/auctex"
> knows which commit to check out.

The first `make packages/auctex` just does

git worktree add packages/auctex externals/auctex

you can `git clone .../auctex.git` there instead.

> And nowhere in the elpa repository do I find some statement that for
> auctex the externals/auctex branch in elpa.git is to be used instead
> of the main or master branch of auctex.git.

It's always built from `externals/`.
The sync between those branches and an upstream (according to `:url`) is
performed separately by another cron job (it could run on another
machine, tho it currently doesn't).

> [1] It just occurred to me that in all mails I've written about an
> externals/elpa branch which is actually externals/auctex.




Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-10 Thread Stefan Monnier
> So just that I get it right, we'd do:
>
>   - Make our former externals/elpa branch the new main branch
> - git checkout -b main externals/elpa && git push
>   - Then clone elpa and setup the infrastructure as you said
>   - Edit elpa-packages locally (but don't yet commit/push)
> - remove `:manual-sync t`
> - add `:branch "main"` and maybe `:make "elpa"`
>   - Then "make packages/auctex" once
>   - while (make auctex.tar is not satisfactory)
> - edit on our new main branch, e.g., refine the elpa target
>   - commit and push the modifications to the auctex recipe in
> elpa-packages

Pretty much, yes.

Note that `make auctex.tar` doesn't care about branches and remote
repositories, it just takes the commit currently found in
`packages/auctex` and makes a tarball from it (IOW things like `:url`, 
`:manual-sync`,
and `:branch` aren't used in the recipe, tho the rest is).

So your first and third steps above can happen at some other time.


Stefan




Re: Making AUCTeX ELPA releases from the master branch

2024-04-09 Thread Stefan Monnier
Tassilo Horn [2024-04-09 14:09:53] wrote:

> Hi all,
>
> some weeks ago, Philip Kaludercic saw a commit of mine triggering a new
> AUCTeX ELPA release and asked why there were changes to files which
> shouldn't be committed because they are generated from other files,
> e.g., info files.
>
> The reason is that at the time where we added AUCTeX to ELPA (and
> created the externals/elpa branch for that purpose), the ELPA machinery
> wasn't able to perform our normal build procedure.  But Stefan Monnier
> chimed in and suggested that nowadays, those issues are most probably
> resolved or can be resolved in some less drastic way than a separate
> branch.  For example, building info manuals from multiple texi files
> residing in subdirectories are no problem anymore (one can specify `:doc
> ("doc/auctex.texi" "doc/preview-latex.texi")` in the ELPA package
> recipe) and we could have a separate elpa target in our Makefile and
> specify that as `:make "elpa"` in package recipe.
>
> I think it would be great if we could make it so that everyone of us
> could trigger a new ELPA release directly from the master branch by just
> incrementing the Version header which currently resides in auctex.el on
> the externals/elpa branch but which is generated from auctex.el.in on
> the master branch so not suitable for a Version header.  But no problem,
> the elpa recipe could specify some different `:main-file`.
>
> So basically, I see these challenges:
>
>   - We set the AUCTeX/preview version and date in the texi files from
> AUCTEXVERSION, AUCTEXDATE, PREVIEWVERSION, and PREVIEWDATE which are
> guessed by autoconf from the ChangeLog.1 and ChangeLog-preview files
> which arranges that the *VERSION is just the same as the *DATE if
> the top entry in the ChangeLogs is not a release entry in which case
> the version is extracted there.
>
> These ChangeLogs aren't usually edited.  Currently, the tarball
> release process prepends the changes since the last tarball release,
> and then the "release manager" (Mosè) adds an entry like
>
> --8<---cut here---start->8---
> 2024-01-17  Mosè Giordano  
>
>   * Version 13.3 released.
> --8<---cut here---end--->8---
>
> on top.  So how should that work for ELPA releases?

For GNU ELPA releases,the "main" place where you keep version numbers
should be your "main file", ideally `auctex.el`.

So your make target will want to extract the version from there instead
of from the ChangeLog.  But that should be easy.  The "right" way would
be to fire an Emacs process and use `package-buffer-info` or just
`lm-header` to fetch the info.  But I'd use a `sed` one-liner.

That won't give you a date, tho.  You could try and use Git to find
a corresponding date, but personally, I'd just use the current date instead.

>   - There's also a completely different alternative: make the
> externals/elpa the new "main" branch and drop master and tarball
> releases altogether.  Is there still a justification for having
> them?  I mean, we dropped XEmacs support anyway and it should be
> easy enough for distros to just use the ELPA tarballs as basis for
> their distro packages.

That's what I'd do if I were you, indeed.  
But note that this will still require tweaking the GNUmakefile to fetch the
Version from the new place and a few things like that and changing the
recipe to add something like `:make "elpa"`.

>   - Mostly to Stefan: How can we test that safely?  I guess we'll find
> some more issues.  I don't want to edit the AUCTeX recipe in
> elpa-packages and then deploy broken packages to users.

You can also try and reproduce the build locally as follows:

git clone --single-branch https://git.sv.gnu.org/git/emacs/elpa
cd elpa
make  # Setup the infrastructure
make packages/auctex  # Create a worktree of the package
make auctex.tar   # Build the tarballs into `auctex.tar`

Note that the tarball is built from *the commit* rather than from the
current set of files (i.e. we start with `git stash` and we `git clean`
as well, IIRC, so be forewarned that it can throw away uncommitted data).

Once that's working, we can install it in `elpa.git` but without
changing the `Version:` header so it doesn't trigger a release: it will
still trigger building a new tarball in GNU-devel ELPA so we can confirm
that it all works according to plans.  And once we're satisfied with
http://elpa.gnu.org/devel/auctex.html, all that remains is to bump up
the `Version:`.


Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-10-27 Thread Stefan Monnier
>> Hmm... this does look awful 
> Exactly. 

How 'bout a hack more like:

(defvar auctex--extra-mode-parent
  '((LaTeX-mode . latex-mode)
...))

(advice-add 'derived-mode-p :after-until #'auctex--compat-derived-mode-p)
(defun auctex--compat-derived-mode-p ( modes)
  (let ((extra-parent (assq major-mode auctex--extra-mode-parent)))
(and extra-parent (memq (cdr extra-parent) modes

?

Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-10-26 Thread Stefan Monnier
>>> (a-2) Now `TeX-add-local-master' adds entry of new mode names such as
>>> %%% Local Variables:
>>> %%% mode: LaTeX  <-- not `latex'
>>> %%% End:
>
>> I don't like this very much: IMO the `mode:` cookie should really not specify
>> the "mode" to use but rather describe the file-type (Emacs could/should
>> aim to support "mime types" kind of names), and then which mode to use
>> for each file-type is decided based on the user's configuration.
>
> I understand your preferance, but I think such discrimination can't be
> much rigorous in practical situations. For example, ConTeXt mode doesn't
> have overlapped mode, so it's most natural to have

Indeed which symbol is used as *the* file-type is somewhat arbitrary.
In the case of ConTeXt, it makes sense to use `ConTeXt-mode`.

And I'd agree that there's also a good case to be made for `LaTeX-mode`,
but history (and general Emacs practice of using lowercase symbols) is
arguing fairly strongly in favor of `latex-mode`.


Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-10-26 Thread Stefan Monnier
>> We should fix this for Emacs-30.
>> [ And then add some backward compatibility hack (presumably using
>>   an advice for when AUCTeX is used on Emacs<30).  ]
> I attach my tentative proposal for Emacs<30, using an advice.

So, IIUC, you're counting on Someone™ to do the work on the Emacs side 

> +(defcustom TeX-hack-former-dir-local-variables nil
> +  "If non-nil, apply dir local vars under former mode names.
> +For example, directory local variables prepared for `latex-mode'
> +will be available in `LaTeX-mode' buffers.
> +It is highly discouraged to enable this option.  Instead, please
> +rewrite mode names in .dir-locals.el whenever possible."

I hope we can arrange the code in Emacs-30 so that no changes are needed
in `.dir-locals.el`, in which case the advice should be activated by
default and we likely shouldn't plead with our users to rewrite their
`.dir-locals.el`.

> +  (setq orig-former-parent (get former 'derived-mode-parent))
> +  (put former 'derived-mode-parent former-parent)
> +  ;; Very ugly hack to deceive `derived-mode-p'.  Suppose
> +  ;;  - aaa-mode is an alias of bbb-mode
> +  ;;  - major-mode value is aaa-mode
> +  ;; Then (derived-mode-p 'aaa-mode) returns nil on Emacs 28 and
> +  ;; later, which makes `dir-locals-collect-variables' ignore a
> +  ;; directory local variable entry for aaa-mode and look for an
> +  ;; entry for bbb-mode instead.  Hence we temporally make
> +  ;; aaa-mode an alias of aaa-mode itself. :-(
> +  (setq orig-former (symbol-function former))
> +  (fset former former)

Hmm... this does look awful 

Some questions/comments about the above comment:

- Indeed, I see that (derived-mode-p 'aaa-mode) returns nil in that
  case, which is a bug.  Do we have a bug-number for that?
  Amusingly, it returns `aaa-mode` if `aaa-mode` is undefined :-)
- Is the problem new in Emacs-28 (if so, I guess it came about
  in the rewrite which introduced `provided-mode-derived-p`).
- How exactly is it related to the issue of activating `latex-mode`
  dir-local settings in `LaTeX-mode`?

I really should look at how best to solve the problem in Emacs-30, it
might give me some ideas about how to write a better workaround for
Emacs<30.

Do you think it would be OK for AUCTeX to declare that `latex-mode` is
*another* parent of `LaTeX-mode`?  The idea is not to allow multiple
inheritance in `define-derived-mode`, but to allow it in `derived-mode-p`.


Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-10-05 Thread Stefan Monnier
> (a) The mode names change as follows:
> plain-tex-mode -> plain-TeX-mode
> latex-mode -> LaTeX-mode
> doctex-mode-> docTeX-mode
> context-mode   -> ConTeXt-mode
> texinfo-mode   -> Texinfo-mode
> ams-tex-mode   -> AmSTeX-mode
> japanese-plain-tex-mode -> japanese-plain-TeX-mode
> japanese-latex-mode -> japanese-LaTeX-mode
> context-en-mode  DELETED
> context-nl-mode  DELETED
> TeX-tex-mode UNCHANGED
> TeX-mode NEW

LGTM.

> (a-2) Now `TeX-add-local-master' adds entry of new mode names such as
> %%% Local Variables:
> %%% mode: LaTeX  <-- not `latex'
> %%% End:

I don't like this very much: IMO the `mode:` cookie should really not specify
the "mode" to use but rather describe the file-type (Emacs could/should
aim to support "mime types" kind of names), and then which mode to use
for each file-type is decided based on the user's configuration.

> (b) All new modes (except TeX-tex-mode) are defined by
> `define-derived-mode'. The inheritance relations are:
[...]
> (c) The compatibility with the former mode names with respect to
> function call are retained by redirections or aliases.

No objection here.

> [Incompatibility]
> 1. directory local variables
>   Currently, directory local variables are prepared in a entry like
>  (latex-mode (reftex-label-alist . (("equation" ?e "eq:%f-" "\\eqref{%s}")
> ("align" ?e "eq:%f-" "\\eqref{%s}")
> ("gather" ?e "eq:%f-" "\\eqref{%s}")
>   in .dir-locals.el. In this feature branch, mode name is `LaTeX-mode',
>   thus this entry is ignored.
>
>   The facility of major-mode-remap-list still does not handle this
>   situation.
>
>   We can announce this fact and ask users to rewrite their
>   .dir-locals.el, but that can't be done if the user doesn't have write
>   access for that particular .dir-locals.el. (Maybe we can ignore such
>   corner cases?)

We should fix this for Emacs-30.
[ And then add some backward compatibility hack (presumably using
  an advice for when AUCTeX is used on Emacs<30).  ]

Maybe using `major-mode-remap-list` is not the right answer, tho (some
settings may be specific to a particular major mode and may cause
problems for other major modes used for the same file-type; I'm
thinking here of remapping between things like doc-view-mode and
pdf-view-mode, or image-mode and postscript-mode, or
image-mode and C-mode (for XPM files), ...).

We should make the directory-local code pay attention to:

- `derived-mode-p`.
- some additional "pseudo-derived-p" thingy for cases like `LaTeX-mode`
  where there isn't a true `derived-mode-p` relation, but the other mode
  can be treated as a sort of parent nevertheless.  Maybe we should change
  `derived-mode-p` so it handles that directly (i.e. offer some way for
  a major mode to declare itself as being a descendant of other
  modeS in addition to its "real" parent.  We could (re)user
  `define-child-mode` for that).

Maybe in addition to that, we need to be able to say in `dir-locals.el`
that a setting applies only for exactly this major mode, and not
its derivatives, maybe with a syntax like:

 ((= latex-mode) (reftex-label-alist
  . (("equation" ?e "eq:%f-" "\\eqref{%s}")
 ("align" ?e "eq:%f-" "\\eqref{%s}")
 ("gather" ?e "eq:%f-" "\\eqref{%s}"

> 2. simple-minded reference to auto-mode-alist in emacs core
>   As discussed in [2], when elisp codes look at auto-mode-alist
>   directly and compare its content with `major-mode', new mode names
>   such as `LaTeX-mode' get no hits and lead to failure.
>   I added workaround for cedet/semantic/symref/grep.el, but similar
>   problematic code still exists at least in cedet/semantic/idle.el:
> --
> (defun semantic-idle-scheduler-work-parse-neighboring-files ()
> ...(snip)...
> ;; Collect all patterns matching files of the same mode we edit.
> (mapc (lambda (pat) (and (eq (cdr pat) major-mode)
>(push (car pat) matching-auto-mode-patterns)))
> auto-mode-alist)
> --

IME, references to the `major-mode` variable in a package is a code
smell :-)

CEDET's code should obey `derived-mode-p` (and its own
`define-child-mode`), indeed.  It shouldn't be hard to do.


Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-09-22 Thread Stefan Monnier
> (defun semantic-symref-derive-find-filepatterns ( mode)
> ...(snip)...
>   (let* ((mode (or mode major-mode))  <-- mode = LaTeX-mode
> ...(snip)...
>   ;; No hit, try auto-mode-alist.
>   (dolist (X auto-mode-alist) <-- Looking at `auto-mode-alist'
>   (when (and (eq (cdr X) mode)
>;; Only take in simple patterns, so try to convert this 
> one.
>(string-match "\\.\\([^\\'>]+\\)'" (car X)))
>   (push (concat "*." (match-string 1 (car X))) pat

Eww.

Right, this code clearly needs to be beefed up if we want it to work
more reliably.  E.g. it needs to check not just (eq (cdr X) mode)
but maybe something like (provided-mode-derived-p (cdr X) mode), so as
to account for derived modes of `mode`, and it needs to use
`major-mode-remap-alist` "in reverse" as well.
And maybe pay attention to function aliases while at it.

IOW it's an ugly heuristic function.

> I suppose that we can work around this issue if
> `semantic-symref-derive-find-filepatterns' is modified to look into
> `major-mode-remap-alist' in emacs 29 and later.  However, I don't see
> clean solution for emacs<29.

Advise `semantic-symref-derive-find-filepatterns` so that if major mode
is `LaTeX-mode` is looks for both `LaTeX-mode` and `latex-mode`?


Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-08-28 Thread Stefan Monnier
>>> 2. ConTeXt modes
>> In the case of `ConTeXt-mode`, maybe the better option is to make the
>> submodes be minor modes?
> Hmm. Some difficulties for that idea come up to my mind:

Well, I did say "maybe" :-)

> 2. As they are minor mode, en-mode and nl-mode can be turned on at the
>same time.

Not necessarily.  E.g. they can share the same (buffer-local) variable,
like `overwrite-mode-binary` and  `overwrite-mode-textual`.

> 3. An entry of the form
> mode: ConTeXt-en
>in file local variable no longer works.

Yeah, you can't name the minor mode `ConTeXt-en-mode` because that needs
to be a function which enables `ConTeXt-mode` as well as the "en" minor mode.
Tho maybe you can have a hack whereby the `ConTeXt-en-mode` minor mode
calls `ConTeXt-mode` if the buffer is not yet using that mode
[ And there's that "maybe" again.  ]

>> In `tex-mode` we've tried various approaches over the years, none of
>> which are elegant :-(
> Now I arrived at another approach without advice which makes use of
> `major-mode-remap-alist'.  How about this idea?

That is indeed part of the motivation behind `major-mode-remap-alist`,
tho I haven't yet tried to push that use to Emacs's `master`.


Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-08-27 Thread Stefan Monnier
>This is much unsatisfactory. I'm currently thinking to apply the
>attached patch to sort out the disorders of mode names. It works as
>follows:
>(a) It uses the names without `TeX-' prefix for LaTeX-mode,
>plain-TeX-mode and TeX-mode.
>(b) Those mode definitions are overwritten, prior to emacs 29, when
>tex-mode.el is loaded. So the patch saves the function
>definitions of AUCTeX major modes in the symbol property
>`auctex-function-definition', and restores them after tex-mode.el
>is loaded via `with-eval-after-load'.

Looks good to me (I mean: it doesn't literally look good, but given what
we have, this seems about as clean as it gets).

Only detail, I'd move the

(if (eq (symbol-function 'plain-TeX-mode) #'plain-tex-mode)
(defalias 'plain-TeX-mode nil))
(if (eq (symbol-function 'LaTeX-mode) #'latex-mode)
(defalias 'LaTeX-mode nil))
(if (eq (symbol-function 'TeX-mode) #'tex-mode)
(defalias 'TeX-mode nil))

into a function and merge it with the similar code which uses
`auctex-function-definition`.

> 2. ConTeXt modes
>The design of ConTeXt modes doesn't match well with
>`define-derived-mode' as explained below.
>ConTeXt modes consist of "primary" mode `ConTeXt-mode' and "sub"
>modes such as `ConTeXt-en-mode' and `ConTeXt-nl-mode'. Sub modes are
>expected to work when they are called explicitly as well.
>At first sight, it seems natural to implement the sub modes as
>derived modes of the primary mode. However, simple implementation
>doesn't work because the primary `ConTeXt-mode' is supposed to
>detect the document's language (english, dutch...) and call the sub
>mode according to the detected language. Thus simple implementation
>leads to loop of the primary mode and duplication of hook calls.
>I chose to implement the sub modes as derived modes of the primary
>mode and move the "detecting the language and calling the sub mode"
>phase of the primary mode into `change-major-mode-after-body-hook'.
>In addition, the phase now bypasses call to the sub mode and calls
>the "body" part of the sub mode independently. Hence the sub mode's
>keymap and hook are ignored in that case. This might be considered as
>a bad behavior.
>In addition, I'm not sure whether such usage is suitable for
>`change-major-mode-after-body-hook' or not.

That's not very pretty, indeed.  The fundamental problem you're trying
to solve is the same as the one we have with `tex-mode` since that
function is used both as "parent mode" and as "dispatch to the
appropriate child-mode".

In `tex-mode` we've tried various approaches over the years, none of
which are elegant :-(

What have now is:

(define-derived-mode tex-mode text-mode "generic-TeX"
  [...]
  (tex-common-initialization))

(advice-add 'tex-mode :around #'tex--redirect-to-submode
;; Give it lower precedence than normal advice, so
;; AUCTeX's advice takes precedence over it.
'((depth . 50)))
(defvar tex-mode--recursing nil)
(defun tex--redirect-to-submode (orig-fun)
  [...]
  (if (or delay-mode-hooks tex-mode--recursing)
[...]))

In the case of `ConTeXt-mode`, maybe the better option is to make the
submodes be minor modes?

If at all possible, I recommend to use different names for the parent
mode and the dispatch function :-)

> 3. Additional menu item
>I chose `text-mode' as the parent of the base mode
>`TeX--VirTeX-mode' and `Texinfo-mode'. This is reasonable because
>those modes called `text-mode-hook' so far. On the other hand, there
>is a side effect that "Text" menu appears in the menu bar in all
>AUCTeX major modes, which may be distracting for some users.

Maybe `nil` (a.k.a. `fundamental-mode`) is a better parent, which more
closely matches the historical behavior of AUCTeX?

TeX is one of those formats that sits halfway between `text-mode` and
`prog-mode` (like (SG|X)ML, as well).

> 4. Directory local variables
>(a) I simplified the way to have `LaTeX-mode' as the value of
>`major-mode' of `japanese-LaTeX-mode' while it can read directory
>local variables prepared for japanese-LaTeX-mode. Now there is a
>line
> :after-hook (setq major-mode 'LaTeX-mode)
>in the definition of `(define-derived-mode japanese-LaTeX-mode...'
>and cumbersome interaction with `hack-local-variables' is
>discarded.
>This solution works for most cases, but would break if the mode
>hooks contain user codes which assume mode name without
>`japanese-' prefix.
>If it turns out that such breakage does exist and no workaround
>is found, we'd have to go back to the former approach.

FWIW, that's a cleaner solution than what I had come up when I looked
at it.


Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-05-11 Thread Stefan Monnier
> d. Directory local variables
>> Maybe the simplest option is to get used to the idea of setting
>> `derived-mode-parent` manually for those modes which are "morally"
>> a child mode, even though the implementation (and behavior) does not
>> inherit much if anything?
>
> Do you mean
> (put 'LaTeX-mode 'derived-mode-parent 'latex-mode)
> ? In that case, `LaTeX-mode' can't have AUCTeX common TeX mode (in my
> personal plan, `TeX-VirTeX-mode') as its parent.

Ah, right, that won't work.

> Is there any way to assign multiple parent modes to `LaTeX-mode'?

Not currently, no.  Allowing `define-derived-mode` to inherit from
multiple modes is technically difficult, but extending
`provided-mode-derived-p` to support multiple parents should be fairly
easy, so maybe we should do that.

> [From your post to bug#61211]
>> I'm also thinking that maybe `set-auto-mode` should remember the name
>> of the "mode function" it called so we could consult this (in addition
>> to the value of `major-mode`) when applying directory-local vars?
> If that is possible, it will be a good solution.

I already save some "old mode" info in `set-auto-mode--last` (for the
purpose of `major-mode-remap-alist`), so maybe all it takes is to use it
in the code handling directory-local variables?

It does run the risk of setting vars for an unrelated mode, but maybe
it's OK (or maybe it needs to use the "old mode" only when the real
mode has no directory-local vars set or something like that)?


Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-05-09 Thread Stefan Monnier
>> Not sure either, but we can arrange to re-instate the aliases (they're
>> not autoloads) upon unload, if so desired (actually, I think all it
>> takes (in Emacs-29) is to use `(defalias 'LaTeX-mode nil)` instead of
>> `(fset 'LaTeX-mode nil)`.  Also, while I'm here, I think we should check
>> that they are aliases before removing them).
> Thanks, I didn't know that `defalias' allows an argument which isn't a
> function. I'll check later.

`defalias` is just like `fset` except that it records the operation as
a "definition" (i.e. for `load-history`, `unload-feature`, ...).
A bit like the difference between `setq` and `defconst/defvar`.

>>> b. Abbrev table User abbrevs in, say, latex-mode-abbrev-table aren't
>>> inherited to AUCTeX LaTeX mode.
>> Is there a particular reason why `LaTeX-mode-abbrev-table` isn't made to
>> inherit from `latex-mode-abbrev-table`?
> No, I think we can manipulate the abbrev table property by
> `abbrev-table-get' and `abbrev-table-put'.

Indeed, you can use those to set the `:parent` property.

> (Or maybe we should add an optional argument to the elisp macro
> `TeX-abbrev-mode-setup' for such an additional parent table.)

Right.  In any case, it's a "small matter of coding".

>>> c. desktop.el records the major mode name in the saved sessions. When
>>> users have saved sessions with the name, say, latex-mode and
>>> install this patch before the next session, desktop.el restores
>>> them in wrong mode in the next session if `major-mode-remap-alist'
>>> is available.
>
>> Indeed, I hadn't thought about that use case.  I can't think of a good
>> way to "fix" it since it seems hard/impossible to reliably detect if
>> that desktop was saved with an Emacs using the "old AUCTeX names" or the
>> "new AUCTeX names".
>
>> The best might be to accept the breakage and add a clear "release note"
>> about it?
>
> Doesn't it help to modify `desktop-restore-file-buffer' to look up
> `major-mode-map-alist' around here?:
> --
> (defun desktop-restore-file-buffer (buffer-filename
> [...]
> (and (not (eq major-mode desktop-buffer-major-mode))
>  (functionp desktop-buffer-major-mode)
>  (funcall desktop-buffer-major-mode))
> --

I think the problem lies elsewhere: when the desktop file says "use
`latex-mode`", how can we distinguish the two cases:

- it's an "old" desktop file, so we should probably redirect it to
  `LaTeX-mode`).
- it's a "new" desktop file but the user really decided to use
  `latex-mode` for that buffer so we should probably not redirect.

Then again, in both cases it's not 100% sure what is the right choice,
so maybe it doesn't matter that much what we do.

>>> d. Directory local variables
>>> d-1
>>> Directory local variables prepared for, say, `latex-mode' aren't
>>> picked up by AUCTeX LaTeX-mode when `major-mode-remap-alist' is
>>> available.
>>> The reason is that `hack-local-variables' doesn't understand
>>> that `LaTeX-mode' is redirected from `latex-mode'.
>
>> This is something that we need to fix before this can make it into
>> a release, I think.  IIRC there's an open bug report on Debbugs
>> about it.
>
> I think you mean bug#61211[1], but it's for type d-2. For type d-1, I
> briefly mentioned in bug#61210[2] as just a subsidary topic.
>
> [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61211
> [2] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61210

Maybe the simplest option is to get used to the idea of setting
`derived-mode-parent` manually for those modes which are "morally"
a child mode, even though the implementation (and behavior) does not
inherit much if anything?

Usually we have the convention that a child mode will call the parent
mode, run the parent mode's hook, that its keymap inherits from the
parent mode's keymap, ... but that's not always practical.

>> Agreed (luckily: making it use `define-derived-mode` would be painful,
>> as you can see in `tex-mode`).
>
> How about separating the two role of `tex-mode'?
> --
> (define-derived-mode tex-base-mode text-mode "generic-TeX"
> [...]
>   (tex-common-initialization))
[...]
> (defun tex-mode ()
>   (funcall (tex--guess-mode)))

This would have as a consequence of changing the parent mode's var
names for the hook, mode map, ...

We could do that, but I think the end result (user-facing names) of the
current solution is fairly "elegant" even though the implementation
isn't.

IOW, I think it's fairly natural to define an "abstract parent mode" and
then arrange for calls to this abstract parent mode to auto-dispatch to
one of the child modes.  But yes, the implementation sucks :-(


Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-05-07 Thread Stefan Monnier
Hi, and thanks, it's great to see concrete movement towards trying to
fix this longstanding issue.

> 1. I'd like to push it to savannah server as a feature branch of AUCTeX
>repository (it isn't ready to merge into master branch yet.) Do you
>think it's OK?

Can't of any reason why not, but I'll leave it to the AUCTeX guys to
give a definitive answer.

>If so, I'm not sure how to do that so I'd like to confirm.

FWIW, here's how I'd do it (using the command line):

git push --set-upstream origin HEAD:feature/fix-mode-names-overlap

>a. Invoked mode
>   a-1
>   Suppose that Alice prefers built-in plain-tex-mode over AUCTeX and
>   customized `TeX-modes' to remove `plain-tex-mode' from it. She
>   also want AUCTeX-style auto-detection for files with .tex
>   extension so leave `tex-mode' in `TeX-modes'. After my patch is
>   applied, when she openes a plain tex file without mode: tag in the
>   File Local Variables section, it's opened in AUCTeX plain TeX mode
>   against her expectation.
>   The reason is that `TeX-tex-mode' calls AUCTeX mode names
>   according to the change in `TeX-format-list'.

Maybe `TeX-format-list` should stay as it is, and `TeX-tex-mode` should
instead rely on `TeX-modes` or `major-mode-remap-alist` to decide which
function to call?

>   a-2
>   Suppose that a site admin sets up AUCTeX as the default TeX modes
>   in site-start.el but Bob disabled them by (unload-feature
>   'tex-site) in his init.el because he prefers built-in modes. In
>   addition, Bob has some latex files annotated with -*- LaTeX -*-,
>   which he recieved from someone else. After my patch is applied,
>   when he opens such a file, it results in File mode specification
>   error.
>   The reason is that tex-site.el is changed to delete the aliases
>   plain-TeX-mode -> plain-tex-mode, LaTeX-mode -> latex-mode.
>
>   I think these are corner cases and am not sure whether we should
>   keep compatibility.

Not sure either, but we can arrange to re-instate the aliases (they're
not autoloads) upon unload, if so desired (actually, I think all it
takes (in Emacs-29) is to use `(defalias 'LaTeX-mode nil)` instead of
`(fset 'LaTeX-mode nil)`.  Also, while I'm here, I think we should check
that they are aliases before removing them).

>b. Abbrev table
>   User abbrevs in, say, latex-mode-abbrev-table aren't inherited to
>   AUCTeX LaTeX mode.

Is there a particular reason why `LaTeX-mode-abbrev-table` isn't made to
inherit from `latex-mode-abbrev-table`?

>c. desktop.el records the major mode name in the saved sessions. When
>   users have saved sessions with the name, say, latex-mode and
>   install this patch before the next session, desktop.el restores
>   them in wrong mode in the next session if `major-mode-remap-alist'
>   is available.

Indeed, I hadn't thought about that use case.  I can't think of a good
way to "fix" it since it seems hard/impossible to reliably detect if
that desktop was saved with an Emacs using the "old AUCTeX names" or the
"new AUCTeX names".

The best might be to accept the breakage and add a clear "release note"
about it?

>d. Directory local variables
>   d-1
>   Directory local variables prepared for, say, `latex-mode' aren't
>   picked up by AUCTeX LaTeX-mode when `major-mode-remap-alist' is
>   available.
>   The reason is that `hack-local-variables' doesn't understand
>   that `LaTeX-mode' is redirected from `latex-mode'.

This is something that we need to fix before this can make it into
a release, I think.  IIRC there's an open bug report on Debbugs
about it.  But it's not even clear what should be a good solution (from
Emacs's point of view).

Maybe in the mean time AUCTeX can "fix" it on its side by adding some
clever piece of advice on the directory-local-vars code or by setting
`derived-mode-parent`?

>   d-2
>   Similar issue related to "superficial major modes" such as
>   japanese-LaTeX-mode still persists for directory local
>   variables[1] regardless whether `major-mode-remap-alist' is
>   available or not.
>   I'm still relying on ugly hack currently used for
>   japanese-{plain-tex,latex}-mode[2].
>
>   [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61211
>   [2] The following code in tex-jp.el.

I hope whichever fix we use for `d-1` will be applicable for `d-2`.

>- TeX-tex-mode is an exception. It doesn't need
>  `define-derived-mode' in my opinion.

Agreed (luckily: making it use `define-derived-mode` would be painful,
as you can see in `tex-mode`).


Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-02-01 Thread Stefan Monnier
>> [ And in Emacs-30, you can use `major-mode-remap-alist` so that
>>   `mode: latex` will not call `latex-mode` but some other function,
>>   such as `LaTeX-mode`.  ]
> Yes, `major-mode-remap-alist` provides a clean way. However AUCTeX still
> need to keep the current code for a certain period for Emacs<30 if we
> take approach [B]. It would take at least several years until AUCTeX
> raises the least supported version to emacs 30.

I think all the possible solutions require such long term planning, yes :-(

>>> - hard-coded mode names in their personal customized codes.
>> I don't know what problem you're thinking of here.
>
> For example, users can have conditionals like
>   (if (eq major-mode 'latex-mode) ...)
> in their personal customized codes assuming that `latex-mode' is
> actually AUCTeX mode.

Ah, right.  Hopefully these are sufficiently uncommon and their users
sufficiently savvy.

>> OTOH you should be able to completely hide the "base" menus (by
>> overriding their bindings with something silly like the `ignore`
>> command).
> Do you mean menus provided by built-in tex mode by "base" menus?

Yes.

> Or "File Edit Options Buffers..."?

No, not these.  This said, those also can be hidden/replaced in the same
way (tho I doubt AUCTeX would want to do that).

> [1] Currently, AUCTeX adds :around advice to `latex-mode' etc.

Indeed, I think this will have to stay at least until Emacs-30 is old
enough that we can rely on `major-mode-remap-alist` (unless we try to
go the minor-mode route).


Stefan




Re: AUCTeX and "builtin latex mode" integration

2023-01-31 Thread Stefan Monnier
> 1. I first tried [A] because [B] wouldn't be easy to retain
> compatibility for users who have
>- a lot of files with "mode: latex" tag in the file local variables
>  section.

The `mode:` specifies which function is called to enable the mode,
rather than which value of `major-mode` will be used in the resulting buffer.

`mode: latex` means that we'll call `latex-mode` and that function can
activate AUCTeX's `LaTeX-mode` (which sets `major-mode` to `LaTeX-mode`)
without any trouble.

[ And in Emacs-30, you can use `major-mode-remap-alist` so that
  `mode: latex` will not call `latex-mode` but some other function,
  such as `LaTeX-mode`.  ]

>- hard-coded mode names in their personal customized codes.

I don't know what problem you're thinking of here.

> The keymaps of AUCTeX LaTeX mode and built-in latex mode have a lot of
> overlaps.

And conflicts, yes :-(

> It seems difficult to me to separate all of them. In
> tex-mode.el, we see:
> --
> (defun tex-define-common-keys (keymap)
>   "Define the keys that we want defined both in TeX mode and in the TeX 
> shell."
>   (define-key keymap "\C-c\C-k" #'tex-kill-job)
>   (define-key keymap "\C-c\C-l" #'tex-recenter-output-buffer)
>   (define-key keymap "\C-c\C-q" #'tex-show-print-queue)
> [...]
>   (define-key keymap "\C-c\C-v" #'tex-view)
> [...]
> (defvar tex-mode-map
>   (let ((map (make-sparse-keymap)))
> [...]
> (define-key map "\"" #'tex-insert-quote)
> (define-key map "\n" #'tex-handle-newline)
> (define-key map "\M-\r" #'latex-insert-item)
> [...]
> (define-key map "\C-c{" #'tex-insert-braces)
> [...]
> (define-key map "\C-c\C-c" #'tex-compile)
> (define-key map "\C-c\C-i" #'tex-bibtex-file)
> (define-key map "\C-c\C-o" #'latex-insert-block)
>
> ;; Redundant keybindings, for consistency with SGML mode.
> (define-key map "\C-c\C-t" #'latex-insert-block)
> [...]
> (define-key map "\C-c/" #'latex-close-block)
>
> (define-key map "\C-c\C-e" #'latex-close-block)
> [...]
> (define-key map "\C-c\C-m" #'tex-feed-input)
> [...]
> (defvar latex-mode-map
>   (let ((map (make-sparse-keymap)))
> [...]
> (define-key map "\C-c\C-s" #'latex-split-block)
> --
> All these key sequences have different binding in AUCTeX (+RefTeX).
> Thus I don't see a clean way to meet the assumption "if we can arrange
> for latex-mode and auctex-mode not to collide in their keymaps".

[ Side note: RefTeX is also used with plan `latex-mode`.  ]

AFAIK the only clean way is to actually change those bindings.
Yes, users will complain, and it may even break some 3rd party code, so
it'll be somewhat painful.

> In addition, I'm afraid that menus and tool bars are intermixed if we
> use `make-composed-keymap' for these two keymaps.

Indeed.  OTOH you should be able to completely hide the "base" menus (by
overriding their bindings with something silly like the `ignore`
command).

> 2. Thus I tried [B] next, in the hope that we can circumvent the above
> mentioned difficulties by similar workarounds employed in the current
> startup codes and announcement to the users.
>
> If we are to take this approach, I think that the new mode name should
> be, e.g., "LaTeX-mode" because the user-exposed functions and variables
> have that prefix now.

Agreed.

> because tex-mode.el has these lines:
> --
> ;;;###autoload
> (defalias 'TeX-mode #'tex-mode)
> ;;;###autoload
> (defalias 'plain-TeX-mode #'plain-tex-mode)
> ;;;###autoload
> (defalias 'LaTeX-mode #'latex-mode)
> --

Yuck!  These need to go!

> Hence I'd like to request to modify the built-in tex-modes.el to delete
> those lines, or at least to do fboundp test like
> (unless (fboundp 'LaTeX-mode)
>   (defalias 'LaTeX-mode #'latex-mode))
> in, say, emacs-30.

Agreed.  Could you open a bug report for that?
(with me in `X-Debbugs-Cc:`)
[ I wouldn't be surprised if there's a bit of reluctance to do that.  ]

> I'd like to discuss dispatch functions context-**-mode and
> japanese-**-mode here. They only do language-specific set-ups and turn
> into context-mode, latex-mode and plain-tex-mode eventually. In some
> aspects, they are similar with guess functions `tex--guess-mode' and
> `TeX-tex-mode':
> - They can be specified as `mode' tag of file local variable and entry
>   of `auto-mode-alist'.
> - They never hold their own `major-mode' value.
> - When called, they eventually turn into another proper major mode.
> Note that it isn't enough to do as
> (define-derived-mode japanese-latex-mode latex-mode "LaTeX"
>   ...
>   (setq major-mode 'latex-mode)
>   ...)
> because it doesn't respond to directory local variable entry of the form
> ((japanese-latex-mode
>   ...))
> in that case.

Hmm... this seems directly relevant to 

Re: AUCTeX and "builtin latex mode" integration

2022-09-25 Thread Stefan Monnier
> Oh, I see where that happens (and why it doesn't happen if we redirect
> with `defalias`).

Hmm... no I still can't reproduce it, even with something else than
a defalias.


Stefan




Re: AUCTeX and "builtin latex mode" integration

2022-09-25 Thread Stefan Monnier
Stefan Monnier [2022-09-25 10:01:40] wrote:
>> 1. Suppose that the file has %%% mode:latex as file variable. When emacs
>> opens this file, it runs `latex-mode' accordingly, which in turn runs
>> AUCTeX `LaTeX-mode' by redirectiton. Then it sets `major-mode' to
>> `LaTeX-mode'.  After that, `hack-local-variables' runs; it sees that
>> `major mode' doesn't match the %%% mode:latex line and runs `latex-mode'
>> again.
> Why would `hack-local-variables` do that ?
> AFAIK vanilla Emacs doesn't do such a thing (I just tried it in
> Emacs-29 to confirm).

Oh, I see where that happens (and why it doesn't happen if we redirect
with `defalias`).


Stefan




Re: AUCTeX and "builtin latex mode" integration

2022-09-25 Thread Stefan Monnier
> be a derived mode of `latex-mode'. However, defining `LaTeX-mode' by
> (define-derived-mode LaTeX-mode latex-mode ...) would cause infinite
> loop when redirection is enabled.

Yes, it's ugly.  That's part of the reason for the weird way we define
`tex-mode` in `tex-mode.el` (and that was preceded by other weird ways
to do it).

I have an idea for how we should solve this in general in Emacs, but in
the mean time a hack like the (or delay-mode-hooks tex-mode--recursing)
I used in `tex--redirect-to-submode` is about as good as I could make
it :-(

> I expect that we can circumvent the difficulty by putting
> `derived-mode-parent' property on `LaTeX-mode', without
> `define-derived-mode'.

That's another option, indeed.


Stefan




Re: AUCTeX and "builtin latex mode" integration

2022-09-25 Thread Stefan Monnier
> 1. Suppose that the file has %%% mode:latex as file variable. When emacs
> opens this file, it runs `latex-mode' accordingly, which in turn runs
> AUCTeX `LaTeX-mode' by redirectiton. Then it sets `major-mode' to
> `LaTeX-mode'.  After that, `hack-local-variables' runs; it sees that
> `major mode' doesn't match the %%% mode:latex line and runs `latex-mode'
> again.

Why would `hack-local-variables` do that ?
AFAIK vanilla Emacs doesn't do such a thing (I just tried it in
Emacs-29 to confirm).


Stefan




Re: AUCTeX and "builtin latex mode" integration

2022-09-23 Thread Stefan Monnier
> Indeed. I learned people are often tempted to use `latex-' prefix to
> customize the behavior of AUCTeX. It means that, in addition to
> `latex-mode-hook', `latex-mode-map' and `latex-mode-syntax-table' (and
> their counterparts of plain-tex-mode, texinfo-mode and doctex-mode) are
> potential sources of similar confusion. :-(
>
> Then the idea of turning AUCTeX into minor mode itself does not help.

Not necessarily, but it could if we can arrange for latex-mode and
auctex-mode not to collide in their keymaps (and syntax table, ...), so
that entries added to `latex-mode-map` wouldn't be hidden by the
auctex-mode-map (e.g. if that map was added with lower priority than
latex-mode-map).

> (a) In addition to being minor mode, AUCTeX uses lower case
> `latex-mode-hook', `latex-mode-map' and `latex-mode-syntax-table'.
> In this case, variable aliases `LaTeX-mode-hook' ->
> `latex-mode-hook' etc. would also be necessary for compatibility.

It could also just run `latex-mode-hook` in addition to what it already
runs, without setting up any alias between that and `LaTeX-mode-hook`.

> (b) AUCTeX abandons the relationship between `LaTeX-mode' and
> `latex-mode'. I.e. `LaTeX-mode' no longer pretends to be
> `latex-mode'.

I think whether it pretends to be is a separate question from whether it
redirects `latex-mode` to its own implementation.

E.g. we could start by setting `major-mode` to `LaTeX-mode` rather than
`latex-mode`.


Stefan




Re: AUCTeX and "builtin latex mode" integration

2022-09-20 Thread Stefan Monnier
> Maybe we could start by stating some goals:
>
> - AUCTeX should not set the `major-mode` to point to
>   non-AUCTeX functions (even if/when it overrides those functions).
>
> - Cleanup the mode function names.  Currently, AUCTeX's LaTeX mode is
>   variously called:
>
> latex-mode
> TeX-latex-mode
> LaTeX-mode
>
>   AUCTeX should pick one and stick to it as much as possible (e.g. fix
>   all the docs and have the auxiliary user-exposed variables be named
>   accordingly to the base major mode name).

Maybe other goals could be to reduce user-confusion by having only "one"
mode, tho it's not clear what that would mean.  But I think we should
come up with a long-term plan (which can include changes in Emacs's
built-in `tex-mode.el`: co-evolution is more difficult, but if we can
agree on a long term plan, we can then figure out how to get there
incrementally).


Stefan


PS: For the record, I'm one of the those Emacs users who doesn't use
AUCTeX: I stopped using AUCTeX many years ago when I decided
that since AUCTeX couldn't be part of Emacs, I should "dogfeed".
Now that it's in GNU ELPA that reason doesn't really apply any more,
but I keep using that mode out of habit.  I'd be just as happy with AUCTeX
which I was using quite happily before.




Re: AUCTeX and "builtin latex mode" integration

2022-09-20 Thread Stefan Monnier
Maybe we could start by stating some goals:

- AUCTeX should not set the `major-mode` to point to
  non-AUCTeX functions (even if/when it overrides those functions).

- Cleanup the mode function names.  Currently, AUCTeX's LaTeX mode is
  variously called:

latex-mode
TeX-latex-mode
LaTeX-mode

  AUCTeX should pick one and stick to it as much as possible (e.g. fix
  all the docs and have the auxiliary user-exposed variables be named
  accordingly to the base major mode name).

WIP patch below.


Stefan


diff --git a/font-latex.el b/font-latex.el
index 4406dea610..577a9834a0 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -36,6 +36,7 @@
 
 (require 'font-lock)
 (require 'tex)
+(require 'latex)
 
 (eval-when-compile
   (require 'cl-lib))
@@ -1285,7 +1286,7 @@ triggers Font Lock to recognize the change."
 
 (defun font-latex--make-syntax-propertize-function ()
   "Return a `syntax-propertize-function' for (La|Doc)TeX documents."
-  (let ((kws ;; (if (derived-mode-p 'doctex-mode)
+  (let ((kws ;; (if (LaTeX--doctex-p)
  ;; font-latex-doctex-syntactic-keywords
font-latex-syntactic-keywords)) ;; )
 (syntax-propertize-via-font-lock kws)))
@@ -1324,7 +1325,7 @@ triggers Font Lock to recognize the change."
 syntax-propertize-wholelines
 font-latex-sp-extend-region-backwards-verb-env
 ;; Add the mode-dependent stuff to the basic variables defined above.
-(if (eq major-mode 'doctex-mode)
+(if (LaTeX--doctex-p)
 (progn
   (setcar defaults (append (car defaults)
'(font-latex-doctex-keywords)))
@@ -1429,7 +1430,8 @@ OPENCHAR is the opening character and CLOSECHAR is the 
closing
 character.  Character pairs are usually { } or [ ].  Comments are
 ignored during the search."
   (let ((parse-sexp-ignore-comments
- (not (eq major-mode 'doctex-mode))) ; scan-sexps ignores comments
+ ;; `scan-sexps' ignores comments.
+ (not (LaTeX--doctex-p)))
 (init-point (point))
 (mycount 1)
 (esc-char (or (and (boundp 'TeX-esc) TeX-esc) "\\"))
@@ -1482,13 +1484,14 @@ ignored during the search."
   (forward-line 0)
   (if (and (eq (char-after) ?\%)
(not (font-latex-faces-present-p 'font-latex-verbatim-face)))
-  (not (eq major-mode 'doctex-mode))
+  (not (LaTeX--doctex-p))
 (catch 'found
   (while (progn (skip-chars-forward "^%" limit)
 (< (point) limit))
 (when (and (save-excursion
  (zerop (mod (skip-chars-backward
-  (regexp-quote esc-char)) 2)))
+  (regexp-quote esc-char))
+ 2)))
(not (font-latex-faces-present-p
  'font-latex-verbatim-face)))
   (throw 'found t))
@@ -1510,7 +1513,7 @@ If POS is omitted, the current position of point is used."
 (defun font-latex-forward-comment ()
   "Like `forward-comment' but with special provisions for docTeX mode.
 In docTeX mode \"%\" at the start of a line will be treated as whitespace."
-  (if (eq major-mode 'doctex-mode)
+  (if (LaTeX--doctex-p)
   ;; XXX: We should probably cater for ^^A as well.
   (progn
 (while (progn (if (bolp) (skip-chars-forward "%"))
@@ -1767,7 +1770,7 @@ cases.")
  (pos (funcall search)))
 (while (and pos
 (member (match-string 1)
-(if (eq major-mode 'doctex-mode)
+(if (LaTeX--doctex-p)
 (remove "_" font-latex-match-simple-exclude-list)
   font-latex-match-simple-exclude-list)))
   (setq pos (funcall search)))
diff --git a/latex.el b/latex.el
index 59ba9cbfc6..02d23803ca 100644
--- a/latex.el
+++ b/latex.el
@@ -894,6 +894,11 @@ position just before \\begin and the position just before
 
 (defvar LaTeX-syntactic-comments) ;; Defined further below.
 
+(defsubst LaTeX--doctex-p ()
+  ;; FIXME: What's the difference between this test and testing
+  ;; `LaTeX-syntactic-comments'?
+  (derived-mode-p 'docTeX-mode))
+
 (defun LaTeX-current-environment ( arg)
   "Return the name (a string) of the enclosing LaTeX environment.
 With optional ARG>=1, find that outer level.
@@ -925,7 +930,7 @@ work analogously."
   ;; comment-prefix.  Hence, the next check just looks
   ;; if we're inside such a group and returns t to
   ;; recognize such a situation.
-  (and (eq major-mode 'doctex-mode)
+  (and (LaTeX--doctex-p)
(member (match-string-no-properties 2)
'("macrocode" "macrocode*"
   (setq arg (if (string= (match-string 1) "end") (1+ arg) (1- arg)
@@ -939,7 +944,8 @@ work analogously."
 (save-excursion
   

Re: AUCTeX and "builtin latex mode" integration

2022-09-20 Thread Stefan Monnier
>>> I wonder why/if it's important that the AUCTeX modes identify as the
>>> builtin modes, i.e., what would be the issue with having (La)TeX-mode
>>> major-modes which have no relationship to (la)tex-mode at all plus a
>>> setup command users would call in their init file in order to modify
>>> `auto-mode-alist' so that the AUCTeX modes are added?
>>
>> It might cause problems for people with `-*- latex -*-` in their
>> files.  But other than that, it's also an option, indeed.
>>
>> Personally, I like the idea that `auto-mode-alist` (and mode cookies)
>> should describe the type of a file, rather than the specific mode to
>> use for it, but that's just me
>
> Could you elaborate a bit here?  I can't quite follow.

What I mean is that the entries in mode cookies and auto-mode-alist
(and magic-mode-alist, ...) should not say "use this specific mode" but
"use the mode which the user chose for files of this specific type".

Emacs doesn't have the corresponding concept, so instead we use
`latex-mode` resp. `perl-mode` as "the name of the mode to use for LaTeX
resp. Perl files" and then we rely on hacks based on `defalias` or
`advice-add` to make that symbol point to the user's favorite mode for
that file type.

> Anyway: where the actual complaints not more or less like "I want to
> use the stock tex/latex modes but also with cdlatex which requires the
> auctex package which then hijacks my editing"?

No (BTW, `cdlatex` doesn't require AUCTeX any more).

> I think that wouldn't be a bad idea anyway (except for compatibility
> reasons) because nowadays we all agree that merely installing and
> loading a package should not have side-effects.

Agreed.  Maybe `AUCTeX-mode` should be a global minor mode which causes
`AUCTeX-minor-mode` to be enabled in the appropriate major modes.


Stefan




Re: AUCTeX and "builtin latex mode" integration

2022-09-20 Thread Stefan Monnier
> 1. Why can't latex-mode not be removed/substituted by auctex?

For technical/administrative/historical reasons.

> 2. What's about reftex? Right now, since auctex provides a mayor
>mode, you can put it in a hook to startup reftex when you open a
>latex file with auctex installed. Would that be a problem, if
>auctex is no longer a «real» mayor mode?

The change would/will introduce breakage.  The intention is to minimize
(and fix) as much of it as possible.  I suspect that if you provide
a test for AUCTeX's test suite verifying this behavior, then we'll make
sure it keeps working :-)


Stefan




Re: AUCTeX and "builtin latex mode" integration

2022-09-20 Thread Stefan Monnier
>> You may have seen an on-going discussion about the annoyance of the
>> mixups between latex-mode and LaTeX-mode and such.
> Could you tell us where that discussion takes place?

I think it's on gnu.emacs.help, aka help-gnu-emacs.

It started with someone complaining that rainbow-delimiters doesn't work
with LaTeX's braces, derived into AUCTeX-vs-plain because IIUC the
problem was that they enabled the mode via `latex-mode-hook` which their
AUCTeX doesn't run even though the mode describes itself as `latex-mode`.

>> I do think it would be good to try and "integrate" the two modes, for
>> some definition of "integrate".  The question being indeed what
>> "integration" is the best way forward.
>
> I also want some improvements with regard to the "integration" because I
> recently realized that emacs built-in `tex-mode' (accidentally?) shadows
> AUCTeX `TeX-tex-mode' since emacs 28.1, to fail to enter LaTeX mode for
> some cases[1][2]. (I'm not sure that the above discussion involves this
> issue.)
>
> [1] thread beginning with
> https://lists.gnu.org/r/auctex/2022-08/msg1.html

Oh, I wasn't aware of regression.  We can workaround the problem
using the `depth` property on `advice-add`, to make sure AUCTeX's advice
takes precedence over that of `tex-mode.el` even if it's
installed before.

E.g. if you add the patch below to Emacs, can you confirm that it fixes
the problem on your end?

diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index f624b604aac..77c0d234206 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1014,7 +1014,10 @@ tex-mode
 says which mode to use."
   (tex-common-initialization))
 
-(advice-add 'tex-mode :around #'tex--redirect-to-submode)
+(advice-add 'tex-mode :around #'tex--redirect-to-submode
+;; Give it lower precedence than normal advice, so
+;; AUCTeX's advice takes precedence over it.
+'((depth . 50)))
 (defvar tex-mode--recursing nil)
 (defun tex--redirect-to-submode (orig-fun)
   "Redirect to one of the submodes when called directly."

I pushed this to `emacs-28` so it will be fixed in the next Emacs
release (but that may be Emacs-29.1).  In the mean time, you can use
a `((depth . -10))` in AUCTeX to make it work with Emacs-28.1.

The dual use of `tex-mode` (as both a major mode and a dispatch
function) is very messy :-(

>> I'm wondering if it would be possible to turn AUCTeX into a minor mode.
>> E.g. `LaTeX-mode` would then be redefined as
>
>> (define-derived-mode TeX-latex-mode latex-mode ...
>>   (AUCTeX-mode 1))
>
>> and `TeX-modes-set` would add/remove `AUCTeX-mode` from the hooks like
>> `latex-mode-hook`.
>
> It basically looks reasonable. I assume that you are thinking that
> `AUCTeX-mode' actually chooses suitable behavior according to the value
> of `major-mode' between `latex-mode', `plain-tex-mode', `doctex-mode'
> and `texinfo-mode'.

That'd be the idea, yes.

> 1. There will be some overheads because it first runs initialization
> codes of emacs built-in mode and then runs AUCTeX minor mode; I expect
> that the associated cost is cheap enough.

I'm assuming it would be cheap, yes.

> 2. AUCTeX still must retain some major modes, i.e., ConTeXt mode,
> AmS-TeX mode, Japanese LaTeX mode and Japanese plain TeX mode because
> there are no counterparts in emacs built-in modes.

In the short term at least it will also keep `(TeX-)LaTeX-mode` and
friends, I think.  And maybe even in the long term.

> 3. Currently, there is defect in handling doc strings of AUCTeX LaTeX
> mode, plain TeX mode and docTeX mode; C-h m and C-h f show doc string
> of built-in modes, not AUCTeX modes.

Maybe the help facility should be more careful in how it builds the
docstring when a function has an `:override` advice, indeed.
Could you `M-x report-emacs-bug` for that?

Maybe the `latex-mode` docstring would need some tweaking, but `C-h m`
would show the docstring of `AUCTeX-mode` as well.

> `AUCTeX-mode' should put suitable `function-documentation' property
> for the respective major mode symbol.

I think that would be exactly the kind of messing around I'd like to
move away from.

> 4. `TeX-tex-mode' and `tex-mode' would need some special treatment.

Special care, that's for sure, yes.

>> To be honest, I haven't looked very much at the code to see how
>> realistic this is, but I think this could help clarify the situation
>> for users. E.g. it would eliminate "lies" such as (setq major-mode
>> 'latex-mode) in `latex.el`.
>
> From the users' point of view, I don't think it matters much. They just
> specify
> %%% mode: latex
> as the file local variable and think that they are using `latex-mode'.
> I think that it would be only Elisp programmers that care about the
> "lies".

There's regularly discussion (among (AUC)TeX Emacs users) about which
major mode runs which hook.  I think it's an important issue not just
for ELisp 

Re: AUCTeX and "builtin latex mode" integration

2022-09-20 Thread Stefan Monnier
Tassilo Horn [2022-09-20 08:38:27] wrote:
> Stefan Monnier  writes:
>> What I'm really asking here is if there's a willingness to introduce
>> the inevitable bit of breakage in exchange for a supposed longer term
>> benefit, and/or if someone can think of a better way to move towards a
>> better long-term arrangement than the status quo.
> I wonder why/if it's important that the AUCTeX modes identify as the
> builtin modes, i.e., what would be the issue with having (La)TeX-mode
> major-modes which have no relationship to (la)tex-mode at all plus a
> setup command users would call in their init file in order to modify
> `auto-mode-alist' so that the AUCTeX modes are added?

It might cause problems for people with `-*- latex -*-` in their files.
But other than that, it's also an option, indeed.

Personally, I like the idea that `auto-mode-alist` (and mode cookies)
should describe the type of a file, rather than the specific mode to use
for it, but that's just me (and Emacs doesn't make that convenient
since it doesn't offer the needed indirection).


Stefan




Re: AUCTeX and "builtin latex mode" integration

2022-09-19 Thread Stefan Monnier
David Kastrup [2022-09-19 23:20:27] wrote:
> Stefan Monnier  writes:
>> I'm wondering if it would be possible to turn AUCTeX into a minor mode.
]...
> Doesn't really seem to fit the conventions for major and minor mode
> keybindings.

Not sure what you mean by that.  Are you presuming that the
`AUCTeX-mode` would place its bindings in the `minor-mode-map-alist`?

If so, no, that's not what I'm suggesting.  We would clearly want
to preserve the current behavior as much as possible, so the
`AUCTeX-mode` minor mode would put its keybindings on the "major mode
map".  Maybe with something like

(use-local-map (make-composed-keymap auctex-mode-map (current-local-map)))

Most minor modes use `minor-mode-map-alist` for their key-bindings, but
there's no rule that imposes this choice.  That are also several minor
modes which either have no key-bindings, or put theirs in
`emulation-mode-map-alists`, or in the global keymap, ...  [ I suspect
there are also minor modes which do something like what I suggest, tho
I must admit that none comes to mind right now.  ]

Depending on the hurdles we encounter when implementing my suggestion,
we might also want to start with a first-cut which only supports
*enabling* the minor mode and burps when someone tries to disable it
since it doesn't seem like it would be the most important functionality:
I'd first and foremost focus on trying to preserve existing
behavior instead.

What I'm really asking here is if there's a willingness to introduce
the inevitable bit of breakage in exchange for a supposed longer term
benefit, and/or if someone can think of a better way to move towards
a better long-term arrangement than the status quo.


Stefan




AUCTeX and "builtin latex mode" integration

2022-09-19 Thread Stefan Monnier
You may have seen an on-going discussion about the annoyance of the
mixups between latex-mode and LaTeX-mode and such.

I do think it would be good to try and "integrate" the two modes, for
some definition of "integrate".  The question being indeed what
"integration" is the best way forward.

I'm wondering if it would be possible to turn AUCTeX into a minor mode.
E.g. `LaTeX-mode` would then be redefined as

(define-derived-mode TeX-latex-mode latex-mode ...
  (AUCTeX-mode 1))

and `TeX-modes-set` would add/remove `AUCTeX-mode` from the hooks like
`latex-mode-hook`.

To be honest, I haven't looked very much at the code to see how
realistic this is, but I think this could help clarify the situation for
users.  E.g. it would eliminate "lies" such as (setq major-mode
'latex-mode) in `latex.el`.  It would also mean that `TeX-latex-mode`
runs `latex-mode-hook`.  There's no doubt that it would introduce some
(presumably minor or easy to fix) breakage in some corner cases for some
exotic configs, of course, but I feel like in the long run it might be
worth it.

WDYT?


Stefan





Re: master 6b5f00bf: Unquote lambdas in font-latex.el & tex-bar.el; add some FIXMEs

2022-08-30 Thread Stefan Monnier
> That's this :help function in LaTeX-symbols-toolbar-switch-contents:
>
> --8<---cut here---start->8---
>:help ,(lambda ( _ignore)
> (concat "Turn "
> (if LaTeX-symbols-toolbar-visible-flag "off " "on ")
> "the toolbar of LaTeX symbols (current class: "
> (nth (1- LaTeX-symbols-active-menuitem)
>  (quote ,list-strings))
> ")")))
> --8<---cut here---end--->8---

Sorry, the

(quote ,list-strings)

should be just

list-strings


-- Stefan




Re: Syntax propertize in font-latex (Re: bug#35140: 12.1; Scan errors in doctex mode with ^^A-comments after braces)

2022-03-07 Thread Stefan Monnier
> I see `syntax-propertize-via-font-lock' is implemented using
> `font-lock-syntactic-keywords' as seen below. Is it planned that
> `syntax-propertize-via-font-lock' survives after
> `font-lock-syntactic-keywords' is removed in Emacs 29?

`syntax-propertize-via-font-lock' is not even declared obsolete (yet?),
so yes, it will survive.


Stefan




Re: Cosmetic patch for AUCTeX

2021-12-29 Thread Stefan Monnier
> Thanks, Mr. Janitor!  The patch looks good to me and its definitely fine
> for our ELPA releases.  However, what about our standard tarball
> releases?  There, Package-Requires has no meaning and we'd inevitable
> need to bump the emacs version requirement to 24.4.  That's basically
> fine with me (24.4 came out in 2014) but requires some discussion.

That's the part only the maintainer of the package can decide ;-)


Stefan




Cosmetic patch for AUCTeX

2021-12-28 Thread Stefan Monnier
The patch below removes the fallback code for when `nadvice` is not
available, replacing it with a dependency on `nadvice-0.3` (which could
be replaced by a dependency on Emacs-24.4).


Stefan


diff --git a/auctex.el b/auctex.el
index da5e667ba4..72d262dc33 100644
--- a/auctex.el
+++ b/auctex.el
@@ -6,7 +6,7 @@
 ;; URL: https://www.gnu.org/software/auctex/
 ;; Maintainer: auctex-devel@gnu.org
 ;; Notifications-To: auctex-di...@gnu.org
-;; Package-Requires: ((emacs "24.3"))
+;; Package-Requires: ((emacs "24.3") (nadvice "0.3"))
 ;; Keywords: TeX LaTeX Texinfo ConTeXt docTeX preview-latex
 
 ;; This file is part of GNU Emacs.
diff --git a/context.el b/context.el
index 139663599e..6914bacb31 100644
--- a/context.el
+++ b/context.el
@@ -640,10 +640,7 @@ for a label to be inserted after the sectioning command."
 
 (TeX-auto-add-type "environment" "ConTeXt")
 
-(if (fboundp 'advice-add)   ;Emacs≥24.4 (or ELPA package nadvice)
-(advice-add 'ConTeXt-add-environments :after #'ConTeXt--invalidate-menu)
-  (defadvice ConTeXt-add-environments (after ConTeXt-invalidate-menu ( 
environments) activate)
-(ConTeXt--invalidate-menu)))
+(advice-add 'ConTeXt-add-environments :after #'ConTeXt--invalidate-menu)
 (defun ConTeXt--invalidate-menu ( _)
   "Mark the menu as being in need of a refresh."
   (setq ConTeXt-menu-changed t))
diff --git a/latex.el b/latex.el
index e1f217f9ca..9d05fc7d7b 100644
--- a/latex.el
+++ b/latex.el
@@ -1985,11 +1985,7 @@ The value is actually the tail of the list of options 
given to PACKAGE."
 
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-auto-cleanup)
 
-(if (fboundp 'advice-add)   ;Emacs≥24.4 (or ELPA package nadvice)
-(advice-add 'LaTeX-add-bibliographies :after #'TeX-run-style-hooks)
-  (defadvice LaTeX-add-bibliographies (after run-bib-style-hooks ( 
bibliographies) activate)
-"Add BIBLIOGRAPHIES to the list of known bibliographies and style files."
-(apply #'TeX-run-style-hooks bibliographies)))
+(advice-add 'LaTeX-add-bibliographies :after #'TeX-run-style-hooks)
 
 ;;; Biber support
 
@@ -6074,10 +6070,7 @@ corresponds to the variables 
`LaTeX-environment-menu-name' and
(mapcar #'LaTeX-environment-modify-menu-entry
(LaTeX-environment-list
 
-(if (fboundp 'advice-add)   ;Emacs≥24.4 (or ELPA package nadvice)
-(advice-add 'LaTeX-add-environments :after #'LaTeX--invalidate-menus)
-  (defadvice LaTeX-add-environments (after LaTeX-invalidate-environment-menu 
( environments) activate)
-(LaTeX--invalidate-menus)))
+(advice-add 'LaTeX-add-environments :after #'LaTeX--invalidate-menus)
 (defun LaTeX--invalidate-menus ( _)
   "Mark the environment menus as being in need of a refresh."
   (setq LaTeX-environment-menu nil)
diff --git a/preview.el b/preview.el
index 0d5ec377ea..bea2adf905 100644
--- a/preview.el
+++ b/preview.el
@@ -2070,11 +2070,6 @@ overlays not in the active window."
   (preview-toggle ovr)
   (push ovr preview-temporary-opened
 
-(if (fboundp 'advice-add)   ;Emacs≥24.4 (or ELPA package nadvice)
-nil ; See the defcustom below.
-  (defadvice replace-highlight (before preview)
-(preview--open-for-replace (ad-get-arg 0) (ad-get-arg 1
-
 (defun preview--open-for-replace (beg end  _)
   "Make `query-replace' open preview text about to be replaced."
   (preview-open-overlays (overlays-in beg end)))
@@ -2086,16 +2081,11 @@ overlays not in the active window."
   :require 'preview
   :set (lambda (symbol value)
  (set-default symbol value)
- (if (fboundp 'advice-add) ; COMPATIBILITY for Emacs<24.4
- (if value
- (advice-add 'replace-highlight :before
- #'preview--open-for-replace)
-   (advice-remove 'replace-highlight
-  #'preview--open-for-replace))
-   (if value
-   (ad-enable-advice 'replace-highlight 'before 'preview)
- (ad-disable-advice 'replace-highlight 'before 'preview))
-   (ad-activate 'replace-highlight)))
+ (if value
+ (advice-add 'replace-highlight :before
+ #'preview--open-for-replace)
+   (advice-remove 'replace-highlight
+  #'preview--open-for-replace)))
   :initialize #'custom-initialize-reset)
 
 (defun preview-relaxed-string= ( args)
diff --git a/tex-site.el b/tex-site.el
index b19a39ee89..4da3076cb1 100644
--- a/tex-site.el
+++ b/tex-site.el
@@ -95,49 +95,22 @@ shared by all users of a site."
 
 (add-hook 'tex-site-unload-hook
   (lambda ()
-(if (fboundp 'advice-add)
-(TeX-modes-set 'TeX-modes nil)
-  (let ((list after-load-alist))
-(while list
-  ;; Adapted copy of the definition of `assq-delete-all'
-  ;; from Emacs 21 as substitute for
-  ;; `(assq-delete-all'TeX-modes-set (car 

Re: Use of lexical binding plus various other things

2021-04-02 Thread Stefan Monnier
> Thanks.  I've found one more occurrence of XEmacs compat code in
> reftex-vars.el.  Can you please install the attached patch as well?
> TIA.

Thanks, pushed.

> Note to myself: We have to adjust RefTeX manual as well and mention the
> removal of XEmacs support.

I believe I just took care of that.


Stefan




Re: Use of lexical binding plus various other things

2021-03-29 Thread Stefan Monnier
> I suggest to apply the following change to reftex-auc.el.  The declared
> functions are defined in ext:latex and not ext:tex; and the name of
> arguments are also corrected.  I don't have access to emacs repo, do you
> mind install the change?

Pushed, thanks,


Stefan




Re: Use of lexical binding plus various other things

2021-03-29 Thread Stefan Monnier
>> Many thanks for this.  I ran `make' in tests directory and get the
>> following error (re-arranged for legibility):
> Thanks for the report. I don't experience such error, so I suppose that
> emacs 28 enhanced check for scope discrepancy between lexical and
> dynamic variables.  (I'm using emacs 27)

Indeed, the error he showed is new in Emacs-28 (whereas Emacs<28 instead
silently does the wrong thing).


Stefan




Re: font-latex-match-warning-make void function.

2021-03-26 Thread Stefan Monnier
> Well, this is a piece of regresstion test suits and the variable in
> question is used only within this particular `ert-deftest'. So I
> presumed it's OK. Is this presumtion wrong?

Do you *need* the variable to be called "var"?  If not, then renaming it
will save you the trouble of wondering under which circumstances it's OK
to use just "var".


Stefan




Re: font-latex-match-warning-make void function.

2021-03-26 Thread Stefan Monnier
>>> I'll try to mess up in a more challenging way next time, I promise.
>> Challenge accepted. :-)
> Well, it seems that we already have a challenge. :-)
> I'm now fixing regression tests, and found that preview.el(.in) still
> needs adaptation because it uses ad-{enable,disable}-advice explicitly.

Damn, I left it too obvious, didn't I?

> Attached is a possible solution. Stefan, is it safe to repeat the same
> `advice-add' or `advice-remove'? That is,

Yes, they're idempotent.

> Experiments seem to suggest that it's safe. But if not, I have to add
> `advice-member-p' test.

Not needed.

>  (if (fboundp 'advice-add)   ;Emacs≥24.4 (or ELPA package nadvice)
> -(advice-add 'replace-highlight :before #'preview--open-for-replace)
> +nil ; See the defcustom below.
>(defadvice replace-highlight (before preview)
>  (preview--open-for-replace (ad-get-arg 0) (ad-get-arg 1

That's right.

> @@ -2073,10 +2073,16 @@ overlays not in the active window."
>:require 'preview
>:set (lambda (symbol value)
>   (set-default symbol value)
> - (if value
> - (ad-enable-advice 'replace-highlight 'before 'preview)
> -   (ad-disable-advice 'replace-highlight 'before 'preview))
> - (ad-activate 'replace-highlight))
> + (if (fboundp 'advice-add) ; COMPATIBILITY for Emacs<24.4
> + (if value
> + (advice-add 'replace-highlight :before
> + #'preview--open-for-replace)
> +   (advice-remove 'replace-highlight
> +  #'preview--open-for-replace))
> +   (if value
> +   (ad-enable-advice 'replace-highlight 'before 'preview)
> + (ad-disable-advice 'replace-highlight 'before 'preview))
> +   (ad-activate 'replace-highlight)))
>:initialize #'custom-initialize-reset)

LGTM.

>  (defun preview-relaxed-string= ( args)
> diff --git a/tests/japanese/preview-latex.el b/tests/japanese/preview-latex.el
> index 9b5f395523..14fc3d1ac9 100644
> --- a/tests/japanese/preview-latex.el
> +++ b/tests/japanese/preview-latex.el
> @@ -274,7 +274,7 @@ String encoded in `shift_jis' can have regexp meta 
> characters in it."
>(let* ((buffer (TeX-process-buffer-name (TeX-master-file nil t)))
>   (process (get-buffer-process buffer)))
>  (if process (delete-process process))
> -(kill-buffer buffer))
> +(if (get-buffer buffer) (kill-buffer buffer)))
>(TeX-clean t)
>(dolist (dir preview-temp-dirs)
>  (if (file-exists-p (directory-file-name dir))

No idea/opinion on that one.

> diff --git a/tests/latex/font-latex-test.el b/tests/latex/font-latex-test.el
> index 7484d03992..f748b3 100644
> --- a/tests/latex/font-latex-test.el
> +++ b/tests/latex/font-latex-test.el
> @@ -24,6 +24,8 @@
>  (require 'ert)
>  (require 'latex)
>  (require 'font-latex)
> +(defvar font-lock-beg)
> +(defvar font-lock-end)
>  
>  (ert-deftest font-latex-three-dollars ()
>"Test three consecutive dollar is ignored."
> @@ -45,8 +47,7 @@ $a$")
>"Test f-l-e-r-b-q doesn't extend region too eagerly."
>(with-temp-buffer
>  (let ((TeX-install-font-lock 'font-latex-setup)
> -  (font-latex-quotes 'french)
> -  font-lock-beg font-lock-end)
> +  (font-latex-quotes 'french))
>(LaTeX-mode)

Good catch, thanks.

> diff --git a/tests/tex/path-expansion.el b/tests/tex/path-expansion.el
> index 2246e92ca8..f19c331965 100644
> --- a/tests/tex/path-expansion.el
> +++ b/tests/tex/path-expansion.el
> @@ -25,6 +25,7 @@
>  
>  (ert-deftest TeX-variable-truncation ()
>"Check whether list variable is not truncated as side effect."
> +  (defvar var)
>(let ((var '("str1" "str2"))
>  (TeX-kpathsea-path-delimiter nil)
>  (TeX-search-files-type-alist

This is going in the right direction but the byte-compiler should
hopefully tell you that this is not quite sufficient: please also rename
`var` to add some namespace prefix to it (I suggest `TeX--var`).


Stefan




Re: font-latex-match-warning-make void function.

2021-03-25 Thread Stefan Monnier
>> Also, I had changes in the `README` which I had to throw out because
>> I couldn't find anything corresponding to it in the auctex.git code.
> The README file is generated from intro.texi and preview-readme.texi in
> auctex.git, so README itself isn't under control of git and is listed in
> .gitignore.

Thanks.
I looked for them by searching for `http:` but of course it returned no
match since those problems had already been fixed in `intro.texi`.
So all is well :-(


Stefan




Re: font-latex-match-warning-make void function.

2021-03-25 Thread Stefan Monnier
> Get your shits together, Stefan,

I'll try to mess up in a more challenging way next time, I promise.

> I've just merged master into externals/auctex.  Could you please check
> if everything's right there, i.e., foremost that changes in *.el.in
> files on master are in the corresponding *.el file in externals/auctex.

That worked fine for preview.el but not for auctex.el, apparently.
[ I'm not surprised: the same thing happened to me when rebasing my
  branch from the elpa.git code to the auctex.git code ;-)  ]

Also, I had changes in the `README` which I had to throw out because
I couldn't find anything corresponding to it in the auctex.git code.

See patch below.
For good measure, I threw in a tweak to `.gitignore`.


Stefan


diff --git a/.gitignore b/.gitignore
index 658ce83fcd..f625e65b26 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 #*
 *.aux
+*.orig
 *.elc
 *.log
 *.synctex.gz
@@ -49,3 +50,7 @@ auctex-autoloads.el
 tests/*/auto/*
 *.dynvars
 auctex-dynvars
+
+# ELPA-generated files
+/auctex-autoloads.el
+/auctex-pkg.el
diff --git a/README b/README
index fe474cf8be..c9a8c12f79 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 This is the README file for the AUCTeX distribution.
 
- Copyright (C) 2008, 2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2021 Free Software Foundation, Inc.
 
  Copying and distribution of this file, with or without
  modification, are permitted in any medium without royalty provided
@@ -48,10 +48,10 @@ new features for your own needs.  It is a GNU project and 
distributed
 under the 'GNU General Public License Version 3'.
 
 The most recent version is always available at
-.
+.
 
 WWW users may want to check out the AUCTeX page at
-.
+.
 
 For comprehensive information about how to install AUCTeX read the file
 'INSTALL' or 'INSTALL.windows', respectively.
@@ -175,7 +175,7 @@ case, 'dvipng' will be used for converting DVI files and 
Ghostscript
 (with a 'PNG' device) for converting PDF files.  'dvipng' is much faster
 than the combination of Dvips and Ghostscript.  You can get downloads,
 access to its CVS archive and further information from its project site
-(http://savannah.nongnu.org/projects/dvipng).
+(https://savannah.nongnu.org/projects/dvipng).
 
 5 More documentation
 
@@ -204,9 +204,9 @@ will display it.
 **
 
 The preview-latex project is now part of AUCTeX and accessible as part
-of the AUCTeX project page (http://savannah.gnu.org/projects/auctex).
+of the AUCTeX project page (https://savannah.gnu.org/projects/auctex).
 You can get its files from the AUCTeX download area
-(ftp://ftp.gnu.org/pub/gnu/auctex).  As of AUCTeX 11.81, preview-latex
+(https://ftp.gnu.org/pub/gnu/auctex).  As of AUCTeX 11.81, preview-latex
 should already be integrated into AUCTeX, so no separate download will
 be necessary.
 
@@ -222,7 +222,7 @@ installation fails (but this should be a rare event), 
report bugs to
 .
 
 There is a general discussion list for AUCTeX which also covers
-preview-latex, look at .
+preview-latex, look at .
 For more information on the mailing list, send a message with just the
 word "help" as subject or body to .  For the
 developers, there is the  list; it would probably
diff --git a/auctex.el b/auctex.el
index ea9d858605..13cc562a15 100644
--- a/auctex.el
+++ b/auctex.el
@@ -1,4 +1,4 @@
-;;; auctex.el --- Integrated environment for *TeX*
+;;; auctex.el --- Integrated environment for *TeX*  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2014-2021 Free Software Foundation, Inc.
 
@@ -6,7 +6,7 @@
 ;; URL: https://www.gnu.org/software/auctex/
 ;; Maintainer: auctex-devel@gnu.org
 ;; Notifications-To: auctex-di...@gnu.org
-;; Package-Requires: ((emacs "24.3") (cl-lib "1.0"))
+;; Package-Requires: ((emacs "24.3"))
 ;; Keywords: TeX LaTeX Texinfo ConTeXt docTeX preview-latex
 
 ;; This file is part of GNU Emacs.




Re: font-latex-match-warning-make void function.

2021-03-25 Thread Stefan Monnier
> At last I managed to figure out the origin and seem to recover the
> normal behavior. Sorry for your inconvinience.

Clearly I'm to blame, so thanks for the fix.




Re: Use of lexical binding plus various other things

2021-03-24 Thread Stefan Monnier
>> Thanks, I'd like to merge them into AUCTeX repository. If nobody
>> objects, I'll do it soon.
> Merged.

Great, thanks!


Stefan




Re: Use of lexical binding plus various other things

2021-03-23 Thread Stefan Monnier
> Oh, I wasn't aware of that! Thank you.
>
> By the way again, here are two very minor issues about your update to
> font-latex.el:
> 1. The doc string of `font-latex-keywords-1' was formerly
> "Subdued level highlighting for LaTeX modes."
> , but is now
> "High level highlighting for LaTeX modes."
> , the same as `font-latex-keywords-2'. I think this is just an
> unintentional mix-up.

Good catch, thanks.  Fixed.

> 2. Now font-locking functions for the default keywords are defined at
> compile time, not load time. Speaking very strictly, this makes
> difference if the user alters the value of
> `font-latex-built-in-keyword-classes' before loading font-latex.elc.

Indeed.  I assumed this is not something that was supported, since there
doesn't seem to be an easy way for the users to *modify* the var (they
could set it to their own choice of value before loading the file, but
then they don't get to benefit from improvements in newer versions).


Stefan




Re: Use of lexical binding plus various other things

2021-03-23 Thread Stefan Monnier
BTW, I rebased my branch on top of your patch, and hence on top of
auctex.git's `master`.


Stefan




Re: Use of lexical binding plus various other things

2021-03-23 Thread Stefan Monnier
>> Duh!  Thanks for the heads up!
>> Indeed, `defadvice` hides the code from the byte-compiler which is why
>> I didn't get a warning for the (boundp 'begin).
>
> I expect that the attached patch makes preview.el.in ready for lexical
> binding...oops, I just noticed that revised commit has been put in on
> elpa!  Maybe my patch is redundant...

I think your patch is much better/cleaner than what I put in my branch
(since it removes those hideous advice), so if you push your patch to
AUCTeX's branch, I'll be happy to rebase my code on top if it.

> By the way, may I ask why many of :group arguments were removed from
> defcustom despite of the existence of correspoinding `defgroup'?

Because they're redundant: since Emacs-21, vars are placed by default
into the group defined in the same file.
[ I did not remove them in those files that define several groups since
  it can be valuable to be explicit in that case.  ]


Stefan




Re: Use of lexical binding plus various other things

2021-03-23 Thread Stefan Monnier
> Duh!  Thanks for the heads up!
> Indeed, `defadvice` hides the code from the byte-compiler which is why
> I didn't get a warning for the (boundp 'begin).
> And I clearly forgot my usual scan of `(set `.

I (force) pushed an updated set of patches which should fix
those problems.


Stefan




Re: Use of lexical binding plus various other things

2021-03-23 Thread Stefan Monnier
> (defadvice TeX-region-create (around preview-counters)
>   "Write out counter information to region."
>   (let ((TeX-region-extra
>  (concat
>   (and (boundp 'begin)
> ^
>preview-buffer-has-counters
>(mapconcat
> #'identity
> (cons
>  ""
>  (preview-counter-find (symbol-value 'begin)))
> ^^^
> "\\setcounter"))
>   TeX-region-extra)))
> ad-do-it))

Duh!  Thanks for the heads up!
Indeed, `defadvice` hides the code from the byte-compiler which is why
I didn't get a warning for the (boundp 'begin).
And I clearly forgot my usual scan of `(set `.


Stefan




Use of lexical binding plus various other things

2021-03-22 Thread Stefan Monnier
I pushed to the branch `scratch/auctex-lexbind` of the `elpa.git`
repository a series of 10 patches which convert all of AUCTeX to use
lexical binding, and includes various other more or less
cosmetic changes.

The commit log is below, the overall patch is too large to be worth
including here.

Please try it out and let me know if you find problems.
Also, feel free to merge any or all parts into AUCTeX's upstream, thanks.


Stefan


commit f8b4d2a9fede599eef619dfeabff7d716d71e250
Author: Stefan Monnier 
Date:   Mon Mar 22 22:56:59 2021 -0400

Use UTF-8 for all ELisp files

UTF-8 is the default encoding used for ELisp files nowadays, so
convert the few remaining exceptions.

* tests/japanese/preview-latex.el:
* tex-jp.el: Remove `coding:` cookie and re-encode into utf-8.

commit 7f10390369ccb82ac19247e5f1eb2c93d6c763a1
Author: Stefan Monnier 
Date:   Mon Mar 22 22:53:55 2021 -0400

Prefer lexical closures over hand-built lambda forms

now that we have lexical-binding, we can use closures, which have the
advantage over `(lambda ...) of allowing the byte-compiler to compile
the code, and also makes it possible to Edebug it.

* preview.el (preview-gs-close, preview-gs-flag-error)
(preview-scale-from-face, preview-gs-flag-error)
(preview-scale-from-face, preview-disabled-string)
(preview-buffer-restore, preview-place-preview)
(preview-reinstate-preview, preview-cache-preamble)
(preview-generate-preview, preview-report-bug):
* toolbar-x.el (toolbarx-emacs-mount-popup-menu):
* tex.el (TeX-mode-specific-command-menu): Replace `(lambda...) with 
closures.

commit 89e707e9d72831c3bfdf41c2274d04c1d4aa797a
Author: Stefan Monnier 
Date:   Mon Mar 22 22:36:40 2021 -0400

Activate lexical-binding everywhere

Also, add an underscore at the beginning of unused arguments to
 silence warnings.

* bib-cite.el (bib-highlight-mouse): Remove unused vars `extent`
and `local-extent-list`.

* latex.el (LaTeX-label): Remove unused var `label`.
(LaTeX-math-mode-map): Move before first use.

* preview.el (preview-start-dvipng, preview-start-dvips):
Remove unused var `file`.

* tex-fold.el (TeX-fold-macro-nth-arg): Remove unused var `close-string`.
(TeX-fold-hide-item): Remove unused var `face`.

* tex-font.el (tex-font-lock-keywords-2): Remove unused var `type`.

* tex-info.el (Texinfo-mark-section): Remove unused var `is-beg-section`.

* toolbar-x.el (toolbarx-test-toolbar-type): Remove unused vars
`all-but-def-opts` and `all-opts`; remove always-t var `good-jobs`.

commit 7eea3ffbac235dd5423587b5406aeb25a997c00d
Author: Stefan Monnier 
Date:   Mon Mar 22 22:20:25 2021 -0400

Miscellaneous minor changes

Move to the next line arguments that are easy to misread.
Fix some commenting style to obey `outline-minor-mode`.

* README: Prefer HTTPS over HTTP/FTP for gnu.org sites.

* bib-cite.el (bib-find-next): Simplify.

* latex.el: Use a non-nil default value for `LaTeX-label-function`
so RefTeX can override it with `add-function`.
(LaTeX-label--default): New function, extracted from `LaTeX-label`.
(LaTeX-label): Use it.
(LaTeX-label-function): Use it as default value.

* toolbar-x.el (toolbarx-emacs-mount-popup-menu): Make the control
flow a bit simpler.
(toolbarx-test-image-type, toolbarx-process-dropdown-group):
Use `car-safe` and strength-reduce `eval` to `symbol-value`.

* style/dinbrief.el: Remove redundant comment.

* style/kpfonts.el (): Simplify.

* style/latexinfo.el (LaTeXinfo-mode-map): Move initialization into
the declaration.

* style/url.el (TeX-arg-urlstyle):
* style/prosper.el (LaTeX-prosper-slide-style-prompt):
Completion tables can be lists of strings.

* style/tikz.el (TeX-TikZ-single-macro-arg): Strength-reduce `eval` to
`apply`.

commit ed126762f6b3f811f3c58abb3eec7a240200cf56
Author: Stefan Monnier 
Date:   Mon Mar 22 21:58:01 2021 -0400

Remove some XEmacs and old-Emacs code

Remove uses of `easy-menu-add` and `easy-menu-remove` which have
always been no-op in Emacs and are declared obsolete in Emacs-28.

* bib-cite.el (bib-cite-setup-highlight-mouse-keymap): Remove Emacs-19 code.

* tex-buf.el (TeX-region-create): Remove use of variable
`font-lock-maximum-size` declared obsolete in Emacs-24.

* toolbar-x.el: Remove left over code from XEmacs compatibility.
Remove XEmacs-only `:toolbar` and `:dropdown-toolbar` as well
`:insert` which was only used to select Emacs-only or XEmacs-only entries.
(toolbarx-default-toolbar-meaning-alist): Replace all uses of
`[Emacs-only XEmacs-only]` vectors with the `Emacs-only` form.

commit 333ae25863dc8d6c358ff588cf9614fddfed7912
Author: Stefan Monnier 
Date:   Mon Mar 22 21:14:57 2021 -0400

Don't quote

TeX-remove-style-hook is local

2020-05-26 Thread Stefan Monnier
I'd like to install the patch below but would like some confirmation
that my understanding is right.

AFAICT, `TeX-auto-add-type` is a macro that's run exclusively at the
top-level of some of AUCTeX's files (context.el, tex.el, and latex.el),
and it uses `add-hook` without a "local" argument in order to add
a function to `TeX-remove-style-hook`, but that variable is declared
buffer-local which makes `add-hook` operate on the buffer-local part of
the hook rather than on the local part.

My understanding is that the intention is to add the function on the
global part of the hook, which is what the patch below does.
If the intention is to add it buffer-locally, then the code will need to
be restructured since the `add-hook` currently runs only when loading
AUCTeX and not when enabling the mode.


Stefan


diff --git a/tex.el b/tex.el
index e8b9e72c5..e89bb25e8 100644
--- a/tex.el
+++ b/tex.el
@@ -1,6 +1,6 @@
 ;;; tex.el --- Support for TeX documents.
 
-;; Copyright (C) 1985-1987, 1991, 1993-2019 Free Software Foundation, Inc.
+;; Copyright (C) 1985-2020 Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Keywords: tex
@@ -2998,7 +2998,6 @@ FORCE is not nil."
 
 (defvar TeX-remove-style-hook nil
   "List of hooks to call when we remove the style specific information.")
- (make-variable-buffer-local 'TeX-remove-style-hook)
 
 (defun TeX-remove-style ()
   "Remove all style specific information."
@@ -3855,6 +3854,7 @@ Generated by `TeX-auto-add-type'.")
;; Append new type to `TeX-auto-parser' in order to make `style' type
;; always the first.
(add-to-list 'TeX-auto-parser ',(list name tmp add local change) t)
+   ;; FIXME: This used to modify only the buffer-local part of the hook!
(add-hook 'TeX-remove-style-hook
 (lambda ()
   (setq ,local nil))




[AUCTeX-diffs] [elpa] externals/auctex 5870187: multi-prompt.el, style/beamer*.el: Get copyright just right

2019-10-16 Thread Stefan Monnier
branch: externals/auctex
commit 58701876d3c30dc54803696d93f430faca04b7a3
Author: Stefan Monnier 
Commit: Stefan Monnier 

multi-prompt.el, style/beamer*.el: Get copyright just right
---
 multi-prompt.el| 3 +--
 style/beamerarticle.el | 2 +-
 style/beamerswitch.el  | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/multi-prompt.el b/multi-prompt.el
index f7632be..98c6dab 100644
--- a/multi-prompt.el
+++ b/multi-prompt.el
@@ -1,7 +1,6 @@
 ;;; multi-prompt.el --- Completing read of multiple strings
 
-;; Copyright (C) 1996, 1997, 2000, 2009, 2014, 2019 Free Software
-;; Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Per Abrahamsen 
 ;; Maintainer: auctex-devel@gnu.org
diff --git a/style/beamerarticle.el b/style/beamerarticle.el
index 2c5cff0..3704e61 100644
--- a/style/beamerarticle.el
+++ b/style/beamerarticle.el
@@ -1,6 +1,6 @@
 ;;; beamerarticle.el --- AUCTeX style for the latex-beamerarticle class
 
-;; Copyright (C) 2019 Free Software Foundation
+;; Copyright (C) 2019 Free Software Foundation, Inc.
 
 ;; Keywords: tex
 
diff --git a/style/beamerswitch.el b/style/beamerswitch.el
index 716d16d..501b375 100644
--- a/style/beamerswitch.el
+++ b/style/beamerswitch.el
@@ -1,6 +1,6 @@
 ;;; beamerswitch.el --- AUCTeX style for the latex-beamerswitch class
 
-;; Copyright (C) 2019 Free Software Foundation
+;; Copyright (C) 2019 Free Software Foundation, Inc.
 
 ;; Keywords: tex
 

___
auctex-diffs mailing list
auctex-di...@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-diffs


Re: [AUCTeX-devel] bug#24070: LaTeX mode doesn't load in 11.89.4

2016-07-27 Thread Stefan Monnier
> I was disabling some of the automatic setup. My original purpose of this
> was to try to reduce my emacs startup time.

In an ideal ELPA world, startup is fast because the automatic setup is
cheap (just a few autoloads and such).  So if the automatic setup is too
slow, that can be for one of two reasons:
- some package(s)'s setup is too expensive.  You should then disable the
  offending package's startup (by setting package-load-list), and report
  the problem to the package's author.
- each package's setup is fast but the overall setup ends up still
  too slow.  Then please M-x report-emacs-bug complaining that ELPA's
  automatic setup time is too expensive and needs to be re-designed.

>> Auto-installing a list of packages seems mostly unrelated to whether
>> (and how) you configure them, tho.
> It does seem that way, but it is convenient (and I'm probably not the one
> to argue on behalf of use-package).

Similarly, I don't see why use of use-package would imply that you
disable the automatic setup done by ELPA.  use-package should
complement it, not replace it.

> I decided to go to extra length to not run (package-initialize) because it
> was significantly slowing my emacs start time and running
> (package-initialize t) made it start faster.

I would appreciate if you could investigate the actual source of slow
down, because it's something that shouldn't happen,


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] bug#24070: LaTeX mode doesn't load in 11.89.4

2016-07-27 Thread Stefan Monnier
> Another problem seems to be that installing AUCTeX from ELPA via use-package
> does not work because that forcefully does (require ') under the
> hoods.

Actually (require 'auctex) does work with the ELPA package *if*
package-initialize was run before (and without a non-nil argument).
Calling package-initialize early on in your ~/.emacs is what should
ideally happen, but IIRC in the OP's case he went to extra length to
disable the normal setup of ELPA packages by calling package-initialize
with a non-nil arg.

> But in any case, it would be good if there would be a big fat warning or
> even error when a user loads auctex manually although it's an ELPA
> install. And obviously I'd prefer if the relevant code was not specific to
> the ELPA branch but was shared between that and master.

Makes sense.

I can't remember enough of how the non-ELPA code works, so feel free to
send me some suggested code or to adjust the code I sent or something.


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] bug#24070: LaTeX mode doesn't load in 11.89.4

2016-07-27 Thread Stefan Monnier
> I have around 30 packages that I install through ELPA.  Since this is pretty
> unwieldy,

I must say that I find it far from obvious that it's unwieldy.

> I have these all configured using the "use-package" macro,

By that do you mean that you first go through the trouble of disabling
the normal automatic setup done by ELPA packages, and then setup
use-package for each and every one of those packages, partly redoing by
hand what the ELPA package's normal setup would have done for you?

> which will automatically download missing packages and `require' them
> as necessary.  This makes installations on new machines really simple.

Auto-installing a list of packages seems mostly unrelated to whether
(and how) you configure them, tho.

> However, since AUCTeX doesn't have any (require 'auctex) line, use-package
> will fail and AUCTeX won't install.

Sounds like a problem with use-package.

> Now that I know that AUCTeX will work when you just install it, it is
> indeed not too hard to get AUCTeX working.

FWIW, this should be the case for *all* ELPA packages.


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] bug#24070: LaTeX mode doesn't load in 11.89.4

2016-07-26 Thread Stefan Monnier
> Sorry, I don't quite understand the purpose of the patch.   Is it
> intended for the ELPA version of AUCTeX or for the upstream package?

The ELPA version.

> The fact that the package is against tex-site.el in ELPA makes me
> think it's for the ELPA version of AUCTeX.  In that case, I don't have
> any objection against trying to make the installation easier for users
> (even if I don't know how the current installation method via ELPA can
> be defined as "hard").

The intent is not to make the installation easier.
It's to make it compatible with the old (require 'tex-site) method.
But as mentioned, maybe rather than make (require 'tex-site) work, it
might be preferable to emit a warning explaining that it's better to
just do nothing and let package-initialize do its job.


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] bug#24070: LaTeX mode doesn't load in 11.89.4

2016-07-26 Thread Stefan Monnier
> Still, this workaround seem a little odd to me.  First, It seems odd that I
> can't start AUCTeX "when I want", i.e., by using the line (load "auctex.el"
> nil t t), even though this worked for me in previous versions of auctex
> (11.89 and 11.88).

Packaging in ELPA aims to follow the way packages bundled with Emacs are
handled, such that they're not "started" automatically, but they are
automatically setup so that you can "start" them by just invoking their
functionality (e.g. loading a .tex file).

> Second, it also seems a little odd that I can't do something like
> (require 'auctex) or (use-package auctex), even though I can load all
> my other 30+ packages that way.  The concept of having nothing in my
> .emacs and the package still being expected to work definitely
> confused me at the beginning.

The only standard/supported way to setup an ELPA package in general is
to load its -autoloads.el file (that's what package-initialize does
usually).  In practice, from what you say, loading .el tends to
work as well, but that's mostly an accident.

This said, AUCTeX has historically been enabled by (load "tex-site") or
(load "auctex"), so it would make sense for AUCTeX's package to support
this.  I thought it worked, but your bug-report shows that it doesn't.

The (untested) patch/hack below might help cases like yours.
I'm not sure if AUCTeX's maintainers want to go that route or would
prefer to just detect the case and emit a warning instead to try and
help people follow the standard installation method.


Stefan


diff --git a/tex-site.el b/tex-site.el
index 44edc54..e59ebc7 100644
--- a/tex-site.el
+++ b/tex-site.el
@@ -1,6 +1,6 @@
 ;;; tex-site.el - Site specific variables.  Don't edit.
 
-;; Copyright (C) 2005, 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2013, 2016 Free Software Foundation, Inc.
 ;;
 ;; completely rewritten.
 
@@ -39,7 +39,14 @@
 ;;; Code:
 
 (if (< emacs-major-version 21)
-  (error "AUCTeX requires Emacs 21 or later"))
+  (error "AUCTeX requires Emacs 21 or later")) ;FIXME: Really?
+
+(unless (or (fboundp 'TeX-modes-set) ;Avoid inf-looping.
+(fboundp 'TeX-tex-mode)) ;auctex-autoloads is not loaded.
+  ;; Try and support the case where someone loads tex-site.el or
+  ;; auctex.el directly, in the old way.
+  (provide 'tex-site);Avoid (re)loading tex-site from auctex-autoloads.
+  (load "auctex-autoloads" 'noerror 'nomessage))
 
 ;; Define here in order for `M-x customize-group  AUCTeX '
 ;; to work if the main AUCTeX files are not loaded yet.

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] Another patch to silence some warnings

2016-05-29 Thread Stefan Monnier
> It just wants to ensure that when you kill the TeX wizard buffer, you
> also exit the recursive edit that it entered.

Then it sounds about right, yes.


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] Another patch to silence some warnings

2016-05-29 Thread Stefan Monnier
>>> Here's another one.
>> Does "another one" mean "another one within a few days"?  Then I
>> probably have missed the first one(s).

No, the other one was a good while ago and the changes are in the
repository, so either you magically came up with the same fixes, or you
didn't miss it ;-)

>> Hm, so I guess what we should do here is set `custom-buffer-done-kill'
>> to t and also add `exit-recursive-edit' to `kill-buffer-hook', both
>> buffer-locally, right?

Sounds OK, yes.  But I haven't had time to actually look at the code to
figure out what it's trying to do.


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


[AUCTeX-devel] Another patch to silence some warnings

2016-05-25 Thread Stefan Monnier
Here's another one.  There's still lots of warnings, and some of the
warnings left in the files I touched below seem serious (e.g. use of
custom-buffer-done-function which seems to be a variable that doesn't
exist).


Stefan


diff --git a/context.el b/context.el
index b962e0d..25151e5 100644
--- a/context.el
+++ b/context.el
@@ -495,6 +495,14 @@ in your .emacs file."
 ConTeXt-section-ref
 ConTeXt-section-section))
 
+;; Define before first use.
+(defcustom ConTeXt-Mark-version "II"
+  "ConTeXt Mark version used for running ConTeXt."
+  :type "string"
+  :group 'TeX-command)
+(make-variable-buffer-local 'ConTeXt-Mark-version)
+(put 'ConTeXt-Mark-version 'safe-local-variable 'stringp)
+
 (defun ConTeXt-numbered-section-heading ()
   "Hook to prompt for ConTeXt section name.
 Insert this hook into `ConTeXt-numbered-section-hook' to allow the user to 
change
@@ -1004,11 +1012,11 @@ If OPTIONAL, only insert it if not empty, and then use 
square brackets."
"[][]\\|"  ; display math delimitors (is this applicable to ConTeXt??)
(ConTeXt-environment-start-name) "\\|"
(ConTeXt-environment-stop-name) "\\|"
-   (mapconcat 'car ConTeXt-numbered-section-list "\\b\\|") "\\b\\|"
-   (mapconcat 'car ConTeXt-unnumbered-section-list "\\b\\|") "\\b\\|"
-   (mapconcat 'identity ConTeXt-extra-paragraph-commands "\\b\\|")
+   (mapconcat #'car ConTeXt-numbered-section-list "\\b\\|") "\\b\\|"
+   (mapconcat #'car ConTeXt-unnumbered-section-list "\\b\\|") "\\b\\|"
+   (mapconcat #'identity ConTeXt-extra-paragraph-commands "\\b\\|")
"\\b\\|"
-   (mapconcat 'identity ConTeXt-item-list "\\b\\|") "\\b\\)"))
+   (mapconcat #'identity ConTeXt-item-list "\\b\\|") "\\b\\)"))
 
 
 ;; Outline support
@@ -1028,14 +1036,14 @@ header is at the start of a line."
"[ \t]*"
(regexp-quote TeX-esc)
"\\("
-   (mapconcat 'ConTeXt-environment-full-start-name ConTeXt-section-block-list 
"\\|") "\\|"
-   (mapconcat 'car ConTeXt-numbered-section-list "\\|")
-   (mapconcat 'car ConTeXt-unnumbered-section-list "\\|")
+   (mapconcat #'ConTeXt-environment-full-start-name ConTeXt-section-block-list 
"\\|") "\\|"
+   (mapconcat #'car ConTeXt-numbered-section-list "\\|")
+   (mapconcat #'car ConTeXt-unnumbered-section-list "\\|")
"\\)\\b"
(if TeX-outline-extra
"\\|"
  "")
-   (mapconcat 'car TeX-outline-extra "\\|")
+   (mapconcat #'car TeX-outline-extra "\\|")
"\\|" (ConTeXt-header-end) "\\b"
"\\|" (ConTeXt-trailer-start) "\\b"))
 
@@ -1063,7 +1071,7 @@ header is at the start of a line."
   "Regular expression that matches a start of all environments mentioned in 
LIST."
   (concat
"start\\("
-   (mapconcat 'identity list "\\|")
+   (mapconcat #'identity list "\\|")
"\\)\\b"))
 
 ;; The top headings are \starttext, \startfrontmatter, \startbodymatter etc.
@@ -1533,55 +1541,55 @@ else.  There might be text before point."
(TeX-update-style)
(setq ConTeXt-menu-changed nil)
(message "Updating section menu...")
-   (mapc 'ConTeXt-section-enable ConTeXt-section-list)
+   (mapc #'ConTeXt-section-enable ConTeXt-section-list)
(message "Updating environment menu...")
(easy-menu-change '("ConTeXt") ConTeXt-environment-menu-name
  (LaTeX-split-long-menu
-  (mapcar 'ConTeXt-environment-menu-entry
+  (mapcar #'ConTeXt-environment-menu-entry
   (ConTeXt-environment-list
(message "Updating modify environment menu...")
(easy-menu-change '("ConTeXt") ConTeXt-environment-modify-menu-name
  (LaTeX-split-long-menu
-  (mapcar 'ConTeXt-environment-modify-menu-entry
+  (mapcar #'ConTeXt-environment-modify-menu-entry
   (ConTeXt-environment-list
(message "Updating define menu...")
(easy-menu-change '("ConTeXt") ConTeXt-define-menu-name
  (LaTeX-split-long-menu
-  (mapcar 'ConTeXt-define-menu-entry
+  (mapcar #'ConTeXt-define-menu-entry
   ConTeXt-define-list)))
(message "Updating setup menu...")
(easy-menu-change '("ConTeXt") ConTeXt-setup-menu-name
  (LaTeX-split-long-menu
-  (mapcar 'ConTeXt-setup-menu-entry
+  (mapcar #'ConTeXt-setup-menu-entry
   ConTeXt-setup-list)))
(message "Updating referencing menu...")
(easy-menu-change '("ConTeXt") ConTeXt-referencing-menu-name
  (LaTeX-split-long-menu
-  (mapcar 'ConTeXt-referencing-menu-entry
+  (mapcar #'ConTeXt-referencing-menu-entry
   ConTeXt-referencing-list)))
(message "Updating other macro's menu...")

Re: [AUCTeX-devel] [Cron Daemon] Cron <elpa@elpa> cd /home/elpa/build && ./admin/update-archive.sh --announce gnu-emacs-sour...@gnu.org

2016-05-24 Thread Stefan Monnier
> Could the ELPA scripts send a mail to the address in .el
> instead of (or in addition to) emacs-devel?  Not everyone who has a
> package on ELPA follows emacs-devel too closely.

Good point,


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


[AUCTeX-devel] Silence compilation warnings

2014-12-03 Thread Stefan Monnier
Here's another patch which silences various compilation warnings, and
fixes a few commenting conventions (noticeable when using
outline-minor-mode).


Stefan


diff --git a/bib-cite.el b/bib-cite.el
index 9ecbc81..164385a 100644
--- a/bib-cite.el
+++ b/bib-cite.el
@@ -1002,6 +1002,16 @@ runs bib-find, and [mouse-3] runs bib-display.
   ^[, \t]*[a-zA-Z]+[ \t]*=[ \t]*\\([a-zA-Z][^#%'(),={}\ \t\n]*\\)
   Regular expression for field containing a @string.)
 
+(defun bib-cite--kind ()
+  (save-excursion
+(if (not (looking-at ))
+(search-backward \\ nil t))
+(if (looking-at bib-ref-regexpc)
+'ref
+  (if (looking-at label{)
+  'label
+'cite
+
 (defun bib-display ()
   Display BibTeX citation or matching \\ref or \\label command under point.
 
@@ -1023,23 +1033,15 @@ string, a second prompt for a ref will be given.
 
 A TAGS file is created and used for multi-file documents under auctex.
   (interactive)
-  (let ((cite)(ref)(label))
-(save-excursion
-  (if (not (looking-at ))
- (search-backward \\ nil t))
-  (if (looking-at bib-ref-regexpc)
- (setq ref t)
-   (if (looking-at label{)
-   (setq label t)
- (setq cite t
+  (let ((kind (bib-cite--kind)))
 (cond
  ;; reftex doesn't handle label-ref
  ((and bib-cite-use-reftex-view-crossref
-  (or ref cite))
+  (memq kind '(ref cite)))
   ;;;FIXME: reftex doesn't want point on \ref or \cite part, but on keyword
   (require 'reftex)
   (reftex-view-crossref nil))
- (cite
+ ((eq kind 'cite)
   (bib-display-citation))
  (t
   (bib-display-label)
@@ -1064,22 +1066,14 @@ string, a second prompt for a ref will be given.
 
 A TAGS file is created and used for multi-file documents under auctex.
   (interactive)
-  (let ((cite)(ref)(label))
-(save-excursion
-  (if (not (looking-at ))
- (search-backward \\ nil t))
-  (if (looking-at bib-ref-regexpc)
- (setq ref t)
-   (if (looking-at label{)
-   (setq label t)
- (setq cite t
+  (let ((kind (bib-cite--kind)))
 (cond
  ;; reftex doesn't handle label-ref
  ((and bib-cite-use-reftex-view-crossref
-  (or ref cite))
+  (memq kind '(ref cite)))
   (require 'reftex)
   (reftex-view-crossref t))
- (cite
+ ((eq kind 'cite)
   (bib-edit-citation))
  (t
   (bib-find-label)
@@ -1236,8 +1230,7 @@ to create a bibtex file containing only the references 
used in the document.
 (when (featurep 'xemacs)
   (defun bib-cite-fontify-help-xemacs (defaults)
 (if (fboundp 'font-lock-set-defaults-1) ; = XEmacs 19.14
-(progn
-  (set-buffer *Help*)
+(with-current-buffer *Help*
   (setq font-lock-defaults-computed nil
 font-lock-keywords nil)
   (font-lock-set-defaults-1
@@ -1247,41 +1240,44 @@ to create a bibtex file containing only the references 
used in the document.
 font-lock-keywords nil)
   (font-lock-set-defaults-1)
 
+(defun bib-cite--fontify-help ()
+  ;; FIXME: This looks ugly and incorrect.
+  (if font-lock-mode
+  (font-lock-mode -1)
+(if (fboundp 'font-lock-unset-defaults) (font-lock-unset-defaults))
+(font-lock-unfontify-buffer))
+  (if (fboundp 'font-lock-ensure)
+  (font-lock-ensure)
+(with-no-warnings (font-lock-fontify-buffer
+
 (defun bib-cite-fontify-help-as-bibtex ()
-  (save-excursion
-(cond
- ((not (featurep 'font-lock))
-  nil)  ;No font-lock! Stop here.
- ;; font-lock under Emacs and XEmacs
- ((featurep 'xemacs)
-  ;; XEmacs
-  (bib-cite-fontify-help-xemacs 'bibtex-mode))
- (t
-  ;; Emacs
-  (set-buffer *Help*)
+  (cond
+   ((not (featurep 'font-lock))
+nil);No font-lock! Stop here.
+   ;; font-lock under Emacs and XEmacs
+   ((featurep 'xemacs)
+;; XEmacs
+(bib-cite-fontify-help-xemacs 'bibtex-mode))
+   (t
+;; Emacs
+(with-current-buffer *Help*
   (let ((font-lock-defaults
-'(bib-cite-bibtex-font-lock-keywords
-  nil t ((?$ . \)(?\ . .)
-   (if (not font-lock-mode)
-   (font-lock-mode 1)
- (if (fboundp 'font-lock-unset-defaults)
- (font-lock-unset-defaults))
- (font-lock-unfontify-buffer))
-   (font-lock-fontify-buffer))
+ '(bib-cite-bibtex-font-lock-keywords
+   nil t ((?$ . \)(?\ . .)
+(bib-cite--fontify-help))
 
 (defun bib-cite-fontify-help-as-latex ()
-  (save-excursion
-(cond
- ((not (featurep 'font-lock))
-  nil)  ;No font-lock! Stop here.
- ;; font-lock under Emacs and XEmacs
- ((featurep 'xemacs)
-  ;; XEmacs, not necessary to do s.th. special for font-latex, we do *not*
-  ;; want the buffer-local faces!
- 

Re: [AUCTeX-devel] [elpa] externals/auctex 7909657: Fix compilation and remove a few more warnings.

2014-11-30 Thread Stefan Monnier
 I cherry-picked the commit from ELPA branch, good to see it works
 flawless!  Thanks.

Good to know, thanks,


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


[AUCTeX-devel] [elpa] externals/auctex 7909657: Fix compilation and remove a few more warnings.

2014-11-28 Thread Stefan Monnier
branch: externals/auctex
commit 7909657676bab72663be6e12dc7e1c4f915b89ba
Author: Stefan Monnier monn...@iro.umontreal.ca
Date:   Fri Nov 28 12:55:20 2014 -0500

Fix compilation and remove a few more warnings.

* tex.el (TeX-view-program-list-builtin): Fix up paren typo.
* preview.el: Cleanup compiler warnings.  Mark unused arguments.
(error): Don't declare; we don't use it anyway.
(view-exit-action): Declare.
(desktop-buffer-preview): Use normal names for the function's args.
(preview-parse-messages): Remove unused vars `error', `context-start',
and `context' (this last one wasn't even bound).
---
 ChangeLog  |   11 +
 preview.el |   73 +--
 tex.el |3 +-
 3 files changed, 49 insertions(+), 38 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cea97e3..34efff3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2014-11-28  Stefan Monnier  monn...@iro.umontreal.ca
+
+   * tex.el (TeX-view-program-list-builtin): Fix up paren typo.
+
+   * preview.el: Cleanup compiler warnings.  Mark unused arguments.
+   (error): Don't declare; we don't use it anyway.
+   (view-exit-action): Declare.
+   (desktop-buffer-preview): Use normal names for the function's args.
+   (preview-parse-messages): Remove unused vars `error', `context-start',
+   and `context' (this last one wasn't even bound).
+
 2014-11-28  Mos� Giordano  m...@gnu.org
 
* tex.el (TeX-view-program-list-builtin): Add the new third
diff --git a/preview.el b/preview.el
index c5556ba..919c098 100644
--- a/preview.el
+++ b/preview.el
@@ -53,7 +53,6 @@ preview-latex buffers will not survive across sessions.)))
 (file-error (message Missing reporter library, probably from the mail-lib 
package:
 preview-latex's bug reporting commands will probably not work.)))
   (require 'info))
-(defvar error)
 
 ;; we need the compatibility macros which do _not_ get byte-compiled.
 (eval-when-compile
@@ -326,7 +325,8 @@ LIST consists of TeX dimensions in sp (1/65536 TeX point).
(consp list)
(let* ((dims (vconcat (mapcar
  #'(lambda (x)
- (/ x 65781.76)) list)))
+ (/ x 65781.76))
+  list)))
  (box
   (vector
(+ 72 (min 0 (aref dims 2)))
@@ -336,13 +336,15 @@ LIST consists of TeX dimensions in sp (1/65536 TeX 
point).
  (border (if preview-parsed-tightpage
  (vconcat (mapcar
#'(lambda(x)
-   (/ x 65781.76)) preview-parsed-tightpage))
+   (/ x 65781.76))
+preview-parsed-tightpage))
(vector (- preview-TeX-bb-border)
(- preview-TeX-bb-border)
preview-TeX-bb-border
preview-TeX-bb-border
- (dotimes (i 4 box)
-   (aset box i (+ (aref box i) (aref border i)))
+ (dotimes (i 4)
+   (aset box i (+ (aref box i) (aref border i
+ box)))
 
 (defcustom preview-gs-command
   (or ;; The GS wrapper coming with TeX Live
@@ -879,7 +881,7 @@ Pure borderless black-on-white will return an empty string.
 (defalias 'preview-dvipng-abort 'preview-dvips-abort)
 ;  Abort a DviPNG run.)
 
-(defun preview-gs-dvips-sentinel (process command optional gsstart)
+(defun preview-gs-dvips-sentinel (process _command optional gsstart)
   Sentinel function for indirect rendering DviPS process.
 The usual PROCESS and COMMAND arguments for
 `TeX-sentinel-function' apply.  Starts gs if GSSTART is set.
@@ -909,7 +911,7 @@ The usual PROCESS and COMMAND arguments for
 (error (preview-log-error err DviPS sentinel process)))
   (preview-reraise-error process))
 
-(defun preview-pdf2dsc-sentinel (process command optional gsstart)
+(defun preview-pdf2dsc-sentinel (process _command optional gsstart)
   Sentinel function for indirect rendering PDF process.
 The usual PROCESS and COMMAND arguments for
 `TeX-sentinel-function' apply.  Starts gs if GSSTART is set.
@@ -965,7 +967,7 @@ The usual PROCESS and COMMAND arguments for
(unless (eq (process-status process) 'signal)
  (preview-dvips-abort)
 
-(defun preview-dvipng-sentinel (process command optional placeall)
+(defun preview-dvipng-sentinel (process _command optional placeall)
   Sentinel function for indirect rendering DviPNG process.
 The usual PROCESS and COMMAND arguments for
 `TeX-sentinel-function' apply.  Places all snippets if PLACEALL is set.
@@ -1114,7 +1116,7 @@ is located.
   t)
 
 
-(defun preview-gs-place (ov snippet box run-buffer tempdir ps-file imagetype)
+(defun preview-gs-place (ov snippet box run-buffer tempdir ps-file _imagetype)
   Generate an image placeholder rendered over by Ghostscript.
 This enters OV into all proper queues in order to make

[AUCTeX-devel] [elpa] externals/auctex updated (6ff4fca - c390682)

2014-11-28 Thread Stefan Monnier
monnier pushed a change to branch externals/auctex.

  from  6ff4fca   Add requires to fix separate compilation.
   new  5211b5e   Create a top level directory in the preview tarball.
   new  19cb9af   Add new TeX-file-line-error option
   new  c2d3585   Update MinionPro style.
   new  f9611ad   Add new styles.
   new  022873b   Fix typo in Makefile.in.
   new  3909e4c   Several changes suggested by byte-compiler warnings.
   new  10de62b   Several changes suggested by byte-compiler warnings.
   new  c72f8a8   Prepare for find-file-hooks being removed from Emacs.
   new  0c2cfc8   Replace `read-string' with `TeX-read-string'
   new  bcea858   Added ChangeLog entries for commit [0c2cfc8]
   new  1997613   Add copyright notice to style/foils.el
   new  43ff21a   Fix documentation about changing font attributes of 
existing text
   new  67756b7   Fix typo
   new  d8dd53d   Update manual
   new  7f64d6c   Update the FAQ entry about failing `TeX-next-error' 
behavior
   new  af12165   Add new `ifluatex.el' style
   new  c4feba1   Add new `luatextra.el' style
   new  0bae61a   Add `ifluatex.el' to Makefile.in
   new  29724a5   Add `luatextra.el' to Makefile.in
   new  daa8a25   Update windows-package Make rule to new Emacs 24.4 
package.
   new  904dfef   Fix structure of the package for Windows.
   new  622c054   Document presence of bashisms in some Make rules.
   new  15edd9b   Omit f-f hooks and more with TeX-region-create
   new  deb1a64   Use more consistent fontification in some styles
   new  e4101ed   Adapt bug intro text for debbugs.
   new  0cb3759   Implement inverse/backward search for TeX regions.
   new  20c7209   Fix fontification of a couple of fontspec macros.
   new  58bd866   Fix indentation in LaTeX-env-figure in a corner case.
   new  a3f4cac   Implement forward-search for View command on TeX-region.
   new  8f7c399   Implement LaTeX-command-section.
   new  acf1c76   Document LaTeX-command-section.
   new  e739b85   Move preview/ to top-level.
   new  e1ec6a0   Make second argument of LaTeX-label optional.
   new  7b427a7   Merge ELPA changes fixing some byte-compile warnings.
   new  59ccf34   Check the viewer executable exists before opening it.
   new  c390682   Merge from upstream.


Summary of changes:
 .gitignore   |   18 ++
 ChangeLog|  377 ++
 ChangeLog-preview|   17 ++
 Makefile-preview.in  |  162 
 Makefile.in  |  152 +++
 auctex.info  |  368 -
 auto-preview.el.in = auto.el.in |0
 autogen.sh   |5 +-
 bib-cite.el  |   84 +
 configure-preview.ac |  226 ---
 configure.ac |  161 +---
 context.el   |   47 +++---
 doc/Makefile.in  |4 +-
 doc/auctex.texi  |   37 +++-
 doc/changes.texi |   12 ++
 doc/faq.texi |   20 +-
 doc/quickstart.texi  |8 +-
 latex.el |  132 +-
 latex/README |   64 ---
 multi-prompt.el  |7 +-
 preview-latex.info   |   76 
 preview.el   |  117 ++--
 prv-install.el   |4 +-
 style/AnonymousPro.el|   90 +
 style/CJK.el |6 +-
 style/MinionPro.el   |   45 ++---
 style/MyriadPro.el   |   90 +
 style/XCharter.el|   76 
 style/amsmath.el |6 +-
 style/amsthm.el  |4 +-
 style/beamer.el  |   20 +-
 style/book.el|4 +-
 style/csquotes.el|4 +-
 style/dinbrief.el|   36 ++--
 style/dk-bib.el  |4 +-
 style/emp.el |   14 +-
 style/epsf.el|6 +-
 style/eso-pic.el |   91 +
 style/filecontents.el|4 +-
 style/foils.el   |   23 +++-
 style/fontaxes.el|  114 
 style/fontspec.el|4 +-
 style/graphicx.el|   40 ++--
 style/ifluatex.el|   61 ++
 style/inputenc.el|4 +-
 style/letter.el  |   18 +-
 style/longtable.el   |4 +-
 style/luatextra.el   |   44 +
 style/mathtools.el   |   10 +-
 style/mdsymbol.el|   99 ++
 style/natbib.el  |8 +-
 style/paralist.el|2 +-
 style/plext.el   |8 +-
 style/prosper.el  

[AUCTeX-devel] [elpa] 01/01: Add requires to fix separate compilation.

2014-11-26 Thread Stefan Monnier
monnier pushed a commit to branch externals/auctex
in repository elpa.

commit 6ff4fca5fc332789c8e295cc38a3334019ccfef1
Author: Stefan Monnier monn...@iro.umontreal.ca
Date:   Wed Nov 26 15:07:23 2014 -0500

Add requires to fix separate compilation.
---
 latex.el |1 +
 preview.el   |3 ++-
 style/acro.el|4 +++-
 style/acronym.el |4 +++-
 style/siunitx.el |2 ++
 5 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/latex.el b/latex.el
index af1c676..549fe67 100644
--- a/latex.el
+++ b/latex.el
@@ -30,6 +30,7 @@
 
 (require 'tex)
 (require 'tex-style)
+(eval-when-compile (require 'cl))
 
 ;;; Syntax
 
diff --git a/preview.el b/preview.el
index 8619ffe..4373084 100644
--- a/preview.el
+++ b/preview.el
@@ -506,7 +506,8 @@ of a cell used for string concatenation.
(t (error Bad string expansion
 
 (defconst preview-expandable-string
-  ((lambda (f) (funcall f (funcall f 'sexp)))
+  (funcall
+   (lambda (f) (funcall f (funcall f 'sexp)))
(lambda (x)
  `(choice
string
diff --git a/style/acro.el b/style/acro.el
index fda4b71..6d74533 100644
--- a/style/acro.el
+++ b/style/acro.el
@@ -1,6 +1,6 @@
 ;;; acro.el --- AUCTeX style for `acro.sty' version 1.2a.
 
-;; Copyright (C) 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Author: Mosè Giordano giordano.m...@libero.it
@@ -29,6 +29,8 @@
 
 ;;; Code:
 
+(require 'tex) ;Indispensable when compiling the call to `TeX-auto-add-type'.
+
 (defvar LaTeX-acro-package-options-list
   '(;; General Options
 (version (0 1))
diff --git a/style/acronym.el b/style/acronym.el
index ea29d1b..b97f80a 100644
--- a/style/acronym.el
+++ b/style/acronym.el
@@ -1,6 +1,6 @@
 ;;; acronym.el --- AUCTeX style for `acronym.sty' version 1.38.
 
-;; Copyright (C) 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Author: Mosè Giordano giordano.m...@libero.it
@@ -29,6 +29,8 @@
 
 ;;; Code:
 
+(require 'tex) ;Indispensable when compiling the call to `TeX-auto-add-type'.
+
 (TeX-auto-add-type acronym LaTeX)
 
 ;; Self Parsing -- see (info (auctex)Hacking the Parser).
diff --git a/style/siunitx.el b/style/siunitx.el
index 9722638..b279cc1 100644
--- a/style/siunitx.el
+++ b/style/siunitx.el
@@ -29,6 +29,8 @@
 
 ;;; Code:
 
+(require 'tex) ;Indispensable when compiling the call to `TeX-auto-add-type'.
+
 (TeX-auto-add-type siunitx-unit LaTeX)
 
 ;; Self Parsing -- see (info (auctex)Hacking the Parser).  `\(?:\[.*\]\)?'

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] [PATCH v2]: Merge /preview/ into top-level

2014-11-15 Thread Stefan Monnier
 I'm not against this change, I'd only like to know if we can avoid to
 move all files around.  For ELPA, I understand the problem is that
 preview.el isn't in the `load-path', we could add preview/ (actually
 (expand-file-name preview TeX-lisp-directory) ) to the `load-path'
 in tex-site.el (is it ok?), but then we'd have to adapt our install
 tree accordingly.
 I'm not exactly sure if having a preview/ subdir is only a load-path
 issue.

ELPA packages are generally expected to put their .el files at the
top-level.  This affects various things, such as the load-path, the
autoloads, and more.  You can hack you way around most of those problems
one way or another, but it's just simpler to move preview to the
top-level and forget about the whole issue.


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] Suggested patch for AUCTeX

2014-11-04 Thread Stefan Monnier
 Oh, I replied only to the list.  Anyway, I've written a CL entry for you
 and committed (at least most parts of) the patch.  A few things I
 couldn't use because XEmacs compatibility, like there's only
 find-file-hooks in XEmacs, no find-file-hook.

find-file-hooks has been obsolete since Emacs-22.1 and I expect to get
rid of it fairly soon.


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] Suggested patch for AUCTeX

2014-11-04 Thread Stefan Monnier
 find-file-hooks has been obsolete since Emacs-22.1 and I expect to get
 rid of it fairly soon.
 Feel free to do that.  Now I've added a defvaralias for XEmacs.

Thanks,


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


[AUCTeX-devel] Suggested patch for AUCTeX

2014-11-02 Thread Stefan Monnier
Here's a patch mostly based on byte-compiler warnings.


Stefan


diff --git a/bib-cite.el b/bib-cite.el
index 612641c..f1a113b 100644
--- a/bib-cite.el
+++ b/bib-cite.el
@@ -1,7 +1,7 @@
 ;;; bib-cite.el --- test
 ;; bib-cite.el - Display \cite, \ref or \label / Extract refs from BiBTeX file.
 
-;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2003, 2004, 2005
+;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2003, 2004, 2005, 
2014
 ;; Free Software Foundation
 
 ;; Author:Peter S. Galbraith p...@debian.org
@@ -724,9 +724,6 @@ These are usually month abbreviations (or journals) defined 
in a style file.
   *Regular expression for \\ref LaTeX commands that have a matching \\label.
 A opening curly bracket is appended to the regexp.)
 
-(defvar bib-cite-is-XEmacs
-  (not (null (save-match-data (string-match XEmacs\\|Lucid emacs-version)
-
 (defvar bib-cite-minor-mode nil)
 
 (defvar bib-highlight-mouse-keymap (make-sparse-keymap)
@@ -762,11 +759,11 @@ runs bib-find, and [mouse-3] runs bib-display.
(progn
  (bib-cite-setup-highlight-mouse-keymap)
  (bib-highlight-mouse)
- (when bib-cite-is-XEmacs
+ (when (featurep 'xemacs)
(make-local-hook 'after-change-functions))
  (add-hook 'after-change-functions
'bib-cite-setup-mouse-function nil t)))
-(if bib-cite-is-XEmacs
+(if (featurep 'xemacs)
(progn
  (or (local-variable-p 'current-menubar (current-buffer))
  (set-buffer-menubar current-menubar))
@@ -775,7 +772,7 @@ runs bib-find, and [mouse-3] runs bib-display.
;;;Undo the minor-mode
 ;; mouse overlay
 (cond
- (bib-cite-is-XEmacs
+ ((featurep 'xemacs)
   (while bib-ext-list
(delete-extent (car bib-ext-list))
(setq bib-ext-list (cdr bib-ext-list
@@ -786,7 +783,7 @@ runs bib-find, and [mouse-3] runs bib-display.
;; FIXME Hope no other package is using them in this buffer!
(remove-text-properties (point-min) (point-max)
'(mouse-face t local-map t)
-(if bib-cite-is-XEmacs
+(if (featurep 'xemacs)
(delete-menu-item '(BCite))
 
 ;;This must be eval'ed when the LaTeX mode is in use.
@@ -803,7 +800,7 @@ runs bib-find, and [mouse-3] runs bib-display.
;;;display the bib-cite stuff (or a subset of it).
(let ((m (copy-keymap (current-local-map
  (cond
-  (bib-cite-is-XEmacs
+  ((featurep 'xemacs)
(set-keymap-name m 'bib-highlight-mouse-keymap)
(cond
 ;;action-key stuff from Vladimir Alexiev vladi...@cs.ualberta.ca
@@ -849,7 +846,7 @@ runs bib-find, and [mouse-3] runs bib-display.
   Unconditionally turn on Bib Cite mode.
   (bib-cite-minor-mode 1))
 
-(defun bib-cite-setup-mouse-function (beg end old-len)
+(defun bib-cite-setup-mouse-function (beg end _old-len)
   (save-excursion
 (save-match-data
   (save-restriction
@@ -893,7 +890,7 @@ runs bib-find, and [mouse-3] runs bib-display.
 
 ;;; Add a menu entry to bibtex.el (Perhaps I should not do this).
 (cond
- ((and (string-match XEmacs\\|Lucid emacs-version)
+ ((and (featurep 'xemacs)
(or window-system
   (fboundp 'smart-menu)))  ;text menus by Bob Weiner
   ;;
@@ -927,7 +924,7 @@ runs bib-find, and [mouse-3] runs bib-display.
 (add-hook 'bibtex-mode-hook 'bib-cite-bibtex-mode-hook))
   )
 
- ((and (not (string-match XEmacs\\|Lucid emacs-version))
+ ((and (not (featurep 'xemacs))
(string-equal 19 (substring emacs-version 0 2))
(or window-system
   (fboundp 'tmm-menubar))) ; 19.30 - Will autoload if necessary
@@ -1160,7 +1157,7 @@ by using bib-apropos sequentially.
   (if (not the-text)
  (message Sorry, no matches found.)
(with-output-to-temp-buffer *Help*
- (mapcar 'princ (nreverse the-text)))
+ (mapc #'princ (nreverse the-text)))
(bib-cite-fontify-help-as-bibtex)
(if bib-novice
(message
@@ -1236,18 +1233,19 @@ to create a bibtex file containing only the references 
used in the document.
   (put-text-property (point-min)(or limit (point-max))
 'face 'red-bold
 
-(defun bib-cite-fontify-help-xemacs (defaults)
-  (if (fboundp 'font-lock-set-defaults-1) ; = XEmcas 19.14
-  (progn
-   (set-buffer *Help*)
-   (setq font-lock-defaults-computed nil
- font-lock-keywords nil)
-   (font-lock-set-defaults-1
-(and defaults (font-lock-find-font-lock-defaults defaults)))
-   (font-lock-fontify-buffer)
-   (setq font-lock-defaults-computed nil
- font-lock-keywords nil)
-   (font-lock-set-defaults-1
+(when (featurep 'xemacs)
+  (defun bib-cite-fontify-help-xemacs (defaults)
+(if (fboundp 'font-lock-set-defaults-1) ; = XEmacs 19.14
+(progn
+  (set-buffer *Help*)
+  (setq font-lock-defaults-computed 

Re: [AUCTeX-devel] Why isn't a new AUCTeX ELPA release triggered?

2014-07-18 Thread Stefan Monnier
 Cc-ing emacs-devel: is there any problem with the package builder on
 ELPA?

I'll check ASAP,


Stefan back online for a couple of days, drowning in the backlog

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] Why isn't a new AUCTeX ELPA release triggered?

2014-07-18 Thread Stefan Monnier
 Cc-ing emacs-devel: is there any problem with the package builder on
 ELPA?

It should work again tonight,


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] Updating the GNU ELPA package of AucTeX

2013-09-03 Thread Stefan Monnier
 It is not clear to me why the act of importing a runnable version of
 AUCTeX into ELPA should be precluded from running a Makefile rule.  It
 is not like ELPA can directly access git repositories and extract
 whatever it wants, so the import will always involve explicit steps.

Yes, GNU ELPA can and does git pull every day as part of its
automatic procedure.

 The new Git ELPA could have the savannah auctex repository as a
 submodule, so there wouldn't be two individual auctex repositories that
 need to me synchronized manually.

That's the intention, indeed (tho not technically as a Git submodule,
but morally equivalent).

 By omitting preview, that would be solved, too.
 preview-latex is an integral part of AUCTeX by now.

I tend to agree with this.  I'm not sure of the potential
technical/documentation problems, but in terms of user expectation
I definitely want preview-latex to be installed when you install auctex.

 Stefan said that the additional auctex/preview/ directory was a problem
 for the ELPA build procedure, so I suggested to have the ELPA auctex
 package not contain it (the directory would still exist in the ELPA
 auctex git submodule).  Then we could possibly have a separate
 preview-latex ELPA package by just symlinking packages/preview-latex to
 packages/auctex/preview/.  So I actually don't propose to rip preview
 out of auctex, just to split it into two ELPA packages in order to cope
 with the simplistic ELPA build procedure.

I'd be OK with splitting auctex into 2 packages, but does preview-latex
work without auctex?  If not, that means we'd need to put the
dependencies in the wrong direction (i.e. users wouldn't automatically
get preview-latex when they install auctex).

It seems simpler to do the mv preview/* ./; rmdir preview.


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] Updating the GNU ELPA package of AucTeX

2013-09-03 Thread Stefan Monnier
 It is not clear to me why the act of importing a runnable version of
 AUCTeX into ELPA should be precluded from running a Makefile rule.
 It is not like ELPA can directly access git repositories and extract
 whatever it wants, so the import will always involve explicit steps.
 Yes, GNU ELPA can and does git pull every day as part of its
 automatic procedure.

 If it expects a package to be in a finished state upon pulling, it means
 that any standard GNU package (which requires ./configure  make 
 sudo make install to work) is not supported.

The GNU guidelines only require for it to be possible to use
./configure  make  make install.  They don't prevent parallel use
of other installation methods.

I can easily accommodate a package with extra files like configure and
Makefile.

 Basically you are asking that we throw away all configurability of
 AUCTeX and convert its repository into an installed tree with a
 neutral configuration.

Not at all.

 How will its Texinfo files get converted into documentation readable as
 PDF or info?  How will its intro.texi get converted into README by
 makeinfo?  After all, every GNU package should have a README, right?
 Our current procedures create this README.

These are indeed the questions I asked.  I proposed 3 ways to do it,
there might be more.  None of these preclude keeping the existing
make rules.

 That's the intention, indeed (tho not technically as a Git submodule,
 but morally equivalent).
 Morally equivalent?  You make it sound like you consider the current
 AUCTeX repository immoral.

Feeling argumentative today?  Reread what I wrote: it is not talking
about AUCTeX but about the technique used to include it in `elpa'.

 I'd be OK with splitting auctex into 2 packages, but does
 preview-latex work without auctex?
 No.  It would be nice to factor out some of its quite sophisticated
 functionality into something independent from AUCTeX, LaTeX and in fact
 also TeX, but at the current point of time preview-latex is not
 independently useful.

I'm not sure you're answering my question, so let me rephrase it: does
it work with tex-mode.el?


Stefan who often uses tex-mode.el rather than AUCTeX, FWIW

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


[AUCTeX-devel] [ELPA-diffs] elpa r415: Bump version number to release the new tex-jp.el

2013-07-03 Thread Stefan Monnier

revno: 415
revision-id: monn...@iro.umontreal.ca-20130703233635-19gmox9sjjwd8ge1
parent: jul...@danjou.info-20130629083454-96bacu87k5h4y2qi
committer: Stefan Monnier monn...@iro.umontreal.ca
branch nick: elpa
timestamp: Wed 2013-07-03 19:36:35 -0400
message:
  Bump version number to release the new tex-jp.el
modified:
  packages/auctex/auctex-pkg.el  auctexpkg.el-20101118182351-xme90jru269t6msr-15
=== modified file 'packages/auctex/auctex-pkg.el'
--- a/packages/auctex/auctex-pkg.el 2012-12-05 16:28:27 +
+++ b/packages/auctex/auctex-pkg.el 2013-07-03 23:36:35 +
@@ -1,1 +1,1 @@
-(define-package auctex 11.86 Integrated environment for *TeX*)
+(define-package auctex 11.86.1 Integrated environment for *TeX*)

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] [ELPA-diffs] /srv/bzr/emacs/elpa r312: Update AUCTeX ELPA package to the new 11.87 release.

2012-12-05 Thread Stefan Monnier
 The XEmacs package building is sort of an aggravation.  An XEmacs
 package contains all necessary files plus info source files in a rigid
 directory layout, possibly not unsimilar to what ELPA or any other
 package would do.

Can you describe how does the XEmacs-package-building relates to the
VCS repository?  Is it that the CVS layout was chosen specifically to
match the XEmacs package requirements?  Are those requirements
incompatible with the ones for ELPA packages?

 So it is not clear to me who the customers for the XEmacs packages we
 compile actually are.

I'll let the AUCTeX maintainer(s) decide whether it's important to
support this.

 However, preview-latex has a somewhat more extensive compatibility
 setup.  It would be arguable not to place the prv-xemacs.el files in
 the ELPA packaging at least.

If a file is in `elpa/packages/auctex' then it will be in the ELPA
package (which is little more than a tarball of that directory).
But I don't see why including prv-xemacs.el in the ELPA package would be
a problem.  It's arguably wasteful, but I doubt anybody cares.

This said, we could tweak the GNU ELPA build scripts so that some files
are removed from the tarball.


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: [AUCTeX-devel] [ELPA-diffs] /srv/bzr/emacs/elpa r312: Update AUCTeX ELPA package to the new 11.87 release.

2012-12-05 Thread Stefan Monnier
 Can you describe how does the XEmacs-package-building relates to the
 VCS repository?  Is it that the CVS layout was chosen specifically to
 match the XEmacs package requirements?
 No.  XEmacs was supported after the CVS layout had been established.  An
 XEmacs package is assembled in a target directory hierarchy separate
 from the source tree.

So it should be easy to adapt the script doing this assembly to work
from the layout in the elpa/paclages/auctex directory.


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel


Re: bug#7053: [AUCTeX-devel] Re: bug#7053: Reftex is fully broken

2010-09-25 Thread Stefan Monnier
 So I contemplate giving up on the separate repository and maintaining
 it in the Emacs repository.  But this should likely be discussed in
 another thread.

You have my vote,


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/auctex-devel


Re: bug#7053: [AUCTeX-devel] Re: bug#7053: Reftex is fully broken

2010-09-20 Thread Stefan Monnier
 bothered to follow the switch to Bazaar.  It might take a while to make
 myself acquainted with it.  And unfortunately I failed to find a web
 interface to the current Emacs sources in order to find out if somebody
 has changed the RefTeX files, or in which way.

 I suspect the change is not in the reftex file but in the behavior of
 up-list which now obeys forward-sexp-function, which means that under
 latex-mode, it will now move from

   \begin{foo}
 here
   \end{foo}
  
 to just before the \begin.  So if the reftex code does not expect that
 (and/or for performance reason doesn't want that), it should protect
 against it by binding forward-sexp-function around calls to up-list
 and friends.

I think in the end, the core reason for the problem was a bug in the new
up-list code (it just silently did nothing when reaching BOB), which
I've just fixed.  I also additionally installed the patch below which
circumvents the bug and also avoids slowing things down unnecessarily.


Stefan


=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog  2010-09-20 21:45:09 +
+++ lisp/ChangeLog  2010-09-20 22:35:46 +
@@ -1,5 +1,9 @@
 2010-09-20  Stefan Monnier  monn...@iro.umontreal.ca
 
+   * textmodes/reftex-parse.el (reftex-what-macro)
+   (reftex-context-substring): Let-bind forward-sexp-function to nil
+   since we don't need/want to treat \begin...\end as a block.
+
* emacs-lisp/lisp.el (up-list): Don't do nothing silently.
 
* simple.el (blink-matching-open): Use syntax-class.

=== modified file 'lisp/textmodes/reftex-parse.el'
--- lisp/textmodes/reftex-parse.el  2010-09-20 13:27:59 +
+++ lisp/textmodes/reftex-parse.el  2010-09-20 22:35:33 +
@@ -385,7 +385,7 @@
 
 (defun reftex-section-info (file)
   ;; Return a section entry for the current match.
-  ;; Carefull: This function expects the match-data to be still in place!
+  ;; Careful: This function expects the match-data to be still in place!
   (let* ((marker (set-marker (make-marker) (1- (match-beginning 3
  (macro (reftex-match-string 3))
  (prefix (save-match-data
@@ -778,13 +778,15 @@
   (narrow-to-region (max (point-min) bound) (point-max))
   ;; move back out of the current parenthesis
   (while (condition-case nil
- (progn (up-list -1) t)
+ (let ((forward-sexp-function nil))
+   (up-list -1) t)
(error nil))
 (setq cnt 1 cnt-opt 0)
 ;; move back over any touching sexps
 (while (and (reftex-move-to-previous-arg bound)
 (condition-case nil
-(progn (backward-sexp) t)
+(let ((forward-sexp-function nil))
+  (backward-sexp) t)
   (error nil)))
   (if (eq (following-char) ?\[) (incf cnt-opt))
   (incf cnt))
@@ -965,15 +967,14 @@
 (if (re-search-forward end{ nil t)
 (match-beginning 0)
   (point-max))
-   ((or (= (preceding-char) ?\{)
-(= (preceding-char) ?\[))
+   ((memq (preceding-char) '(?\{ ?\[))
 ;; Inside a list - get only the list.
 (buffer-substring-no-properties
  (point)
  (min (+ (point) 150)
   (point-max)
   (condition-case nil
-  (progn
+  (let ((forward-sexp-function nil)) ;Unneeded fanciness.
 (up-list 1)
 (1- (point)))
 (error (point-max))


___
auctex-devel mailing list
auctex-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/auctex-devel


Re: bug#7053: [AUCTeX-devel] Re: bug#7053: Reftex is fully broken

2010-09-18 Thread Stefan Monnier
 Since I've never gotten commit access to the Emacs repository I haven't

That should be easy to fix.  Get a Savannah account, and from there, ask
for membership to the Emacs group.

 bothered to follow the switch to Bazaar.  It might take a while to make
 myself acquainted with it.  And unfortunately I failed to find a web
 interface to the current Emacs sources in order to find out if somebody
 has changed the RefTeX files, or in which way.

I suspect the change is not in the reftex file but in the behavior of
up-list which now obeys forward-sexp-function, which means that under
latex-mode, it will now move from

  \begin{foo}
 here
  \end{foo}
  
to just before the \begin.  So if the reftex code does not expect that
(and/or for performance reason doesn't want that), it should protect
against it by binding forward-sexp-function around calls to up-list
and friends.


Stefan

___
auctex-devel mailing list
auctex-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/auctex-devel


[AUCTeX-devel] Re: BibTeX-mode: Key generation when latin-1 characters appear in author field

2007-08-02 Thread Stefan Monnier
 text-mode:Grüß Gott
 tex-mode: Gr\u{\ss} Gott
 german latex-mode:Grus Gott
 html-mode:Gruuml;szlig; Gott

AFAIK, nowadays in LaTeX, you're better off using Grüß Gott with the
proper input encoding.  For HTML mode as well.

ELISP (reftex-latin1-to-ascii räksmörgås)

Before trying to solve the problem for latin-1, then latin-2, then arabic,
then chinese, etc.. we'd better write a real fix that correctly (tho
suboptimally) handles all cases: drop non-ascii chars.  Then we can add
a preprocessing function that tries to be clever.


Stefan


___
auctex-devel mailing list
auctex-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/auctex-devel


[AUCTeX-devel] Re: BibTeX-mode: Key generation when latin-1 characters appear in author field

2007-08-02 Thread Stefan Monnier
 Does drop non-ascii chars mean that räksmörgås becomes rksmrgs,
 or raksmorgas? I'm afraid you mean the former ... But what would
 such a function do to a Greek/Cyrillic/Japanese BibTeX entry? I'd
 guess there is nothing left when you drop non-ascii chars.

Yup, there's nothing left.  So what: we're talking about a suggestion to put
in the minibuffer.


Stefan


___
auctex-devel mailing list
auctex-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/auctex-devel


[AUCTeX-devel] Re: Usage of install.el

2007-02-28 Thread Stefan Monnier
 One could achieve this with a two-step approach of creating a package and
 then installing it, of course.
 
 Yes.  Although right now there's no code to actually *create* a package ;-)

 I know, and I am wondering if install.el would be the right place for
 including that functionality because the creation of a package can be
 very special.

Agreed.  Which is one of the reasons why there is no such code right now.


Stefan


___
auctex-devel mailing list
auctex-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/auctex-devel


[AUCTeX-devel] Re: Usage of install.el

2007-02-25 Thread Stefan Monnier
 As far as I can see the intent is to extract a tar ball at a target
 location, e.g. site-lisp, and then compile everything in place.

Yes, pretty much.  The all-in-one-place end result is what
really matters.  It makes package management tremendously easier:
- no need to track sets of files installed per package
- self-sufficient directory that can be moved at will (or that can have
  multiple names at the same time even)

How to get at this end result doesn't matter as much.  But it seems that
untar is a fairly attractive way to do that ;-)

 My thoughts about this are a bit ambiguous.  On the one hand this enforces
 the notion of a package keeping everything in one place.  This way it will
 also be easier to update or remove a package.  On the other hand this
 might leave some unwanted cruft in the target location, e.g. distribution
 files like INSTALL or README.

Yes, it's something that I haven't tried to address yet, but as long as
they're in a different directory than the .el(c) or texi/info files, it's
not really problematic.  The package format needs to provide hooks for
various special cases anyway, so it could allow a list of files to be
deleted after untarring.

 (Of course, those might not be necessary anymore once something like
 install.el is established.)

My crystal ball doesn't care to look that far into the future.

 And e.g. an info file might have to be copied to a directory where the
 standalone info reader can find it nevertheless.

Hmm... since these are Elisp packages it seemed sufficient to make them
available only from Emacs's Info browser.  I guess hooks could take care to
add symlinks/copies/whatnot into other info directories.  Not very
satisfactory, but this seems to be seriously out of the scope of the simple
approach of install.el.

 I like the idea of keeping everything in one place.  What I am
 currently thinking about is if there should be a mechanism of
 producing a clean package tar ball (which might also mean to change
 the directory layout in order to be able to create a package suitable
 for XEmacs) and if install.el should be able to be used during
 development, i.e. for installing a package straight from the
 development sources.

Right now I use install-directory-in-place for that.  Not sure if it
addresses your needs.

 One could achieve this with a two-step approach of creating a package and
 then installing it, of course.

Yes.  Although right now there's no code to actually *create* a package ;-)


Stefan


___
auctex-devel mailing list
auctex-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/auctex-devel


  1   2   >