Re: [AUCTeX-devel] Small patch for subfiles.el
Hi Arash, 2017-02-20 21:23 GMT+01:00 Arash Esbati : > Hi Mosè, > > Mosè Giordano writes: > >> Not for me, and I guess nor for Arash :-/ > > Did you patched subfiles.el with > > (TeX-run-style-hooks > (file-name-sans-extension > (cadr (assoc "subfiles" LaTeX-provided-class-options > > as you tried it or did you just evaluate it in a .tex file? I did patch and compile the file, but I can't tell what was the problem then. Now that's working for you, Keita and me I installed the fix (together with an improvement to the regexp to determine whether there is the `documentclass' macro). Bye, Mosè ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
Hi Mosè, Mosè Giordano writes: > Not for me, and I guess nor for Arash :-/ Did you patched subfiles.el with (TeX-run-style-hooks (file-name-sans-extension (cadr (assoc "subfiles" LaTeX-provided-class-options as you tried it or did you just evaluate it in a .tex file? Best, Arash ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
Hi Keita, Ikumi Keita writes: >> I think this can be fixed by adding > >> (dolist (name TeX-style-path) >>(TeX-load-style-file (expand-file-name style name))) > >> to second condition as well. > > Is that really necessary? On my environment, just replacing > `file-name-base' with `file-name-sans-extension' in subfiles.el seems > enough. After that replacement, a subfile which has > \documentclass[../../main.tex]{subfiles} > loads ../../auto/main.el, without modifying `TeX-load-style'. many thanks for double-checking. Indeed, you're right, the last part of my analysis was wrong. With `file-name-sans-extension', everything works just fine. I think I did something else wrong in my test case so that I came up with that wrong observation. > I suppose that the problem of the Uwe's comment >> I still don't understand why auctex scans >> \documentclass[../main.tex]{subfiles} >> >> But not. >> \documentclass[../../main.tex]{subfiles} > will also be resolved by replacing `file-name-base' with > `file-name-sans-extension' in subfiles.el. That is, both "../main.tex" > case and "../../main.tex" case work correctly. (On the other hand, I > have no idea why the former worked without that replacement.) Same at my end. But I had enough subfiles today, maybe tomorrow :-) Best, Arash ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
Hi Keita, 2017-02-20 19:30 GMT+01:00 Ikumi Keita : > Hi Arash, > >> I think this can be fixed by adding > >> (dolist (name TeX-style-path) >>(TeX-load-style-file (expand-file-name style name))) > >> to second condition as well. > > Is that really necessary? On my environment, just replacing > `file-name-base' with `file-name-sans-extension' in subfiles.el seems > enough. After that replacement, a subfile which has > \documentclass[../../main.tex]{subfiles} > loads ../../auto/main.el, without modifying `TeX-load-style'. Not for me, and I guess nor for Arash :-/ Bye, Mosè ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
Hi Arash, > I think this can be fixed by adding > (dolist (name TeX-style-path) >(TeX-load-style-file (expand-file-name style name))) > to second condition as well. Is that really necessary? On my environment, just replacing `file-name-base' with `file-name-sans-extension' in subfiles.el seems enough. After that replacement, a subfile which has \documentclass[../../main.tex]{subfiles} loads ../../auto/main.el, without modifying `TeX-load-style'. > When invoked as (TeX-load-style "../../main-file.tex") from > `TeX-run-style-hooks' (with `file-name-sans-extension' as you suggested, > of course), `TeX-load-style' sees a complex path and starts the second > condition. But then, it makes a recursive call to (TeX-load-style > style) which is (TeX-load-style "main-file"). Now the t condition is > called and (TeX-load-style-file ...) does not find any auto generated > file it standard style path since the additions of the first run are > lost. I agree most part of this analysis, but the last part > since the additions of the first run are lost. does not seem to apply. The recursive call is done with the variable `TeX-style-path' assigned a new local value by `let*' statement as > (TeX-style-path (append (list (expand-file-name > TeX-auto-local dir) > (expand-file-name > TeX-auto-local master-dir) > (expand-file-name > TeX-style-local dir) > (expand-file-name > TeX-style-local master-dir)) > TeX-style-path))) , so the `dolist' loop in the t condition does find "../../auto/main.el", I think. I suppose that the problem of the Uwe's comment > I still don't understand why auctex scans > \documentclass[../main.tex]{subfiles} > > But not. > \documentclass[../../main.tex]{subfiles} will also be resolved by replacing `file-name-base' with `file-name-sans-extension' in subfiles.el. That is, both "../main.tex" case and "../../main.tex" case work correctly. (On the other hand, I have no idea why the former worked without that replacement.) Regards, Ikumi Keita ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
>>> "Arash" == Arash Esbati writes: > Uwe Brauer writes: >> I just did. I restarted emacs, entered a subfiles with that path >> structure, the style subfiles.el was not loaded. >> >> I evaluated your lisp code and voila: it works like charm, subfiles.el >> is loaded and supports the editing as it should. > Thanks for checking. I have a question, though: What do you mean with > `subfiles.el is loaded'? That specific style from AUCTeX should be > loaded anyway since you have \documentclass{subfiles} in your sub file > document. The idea was that the parsed style file for your master > document "../../main-file.tex", e.g. "../../auto/main-file.el", is > loaded and consequently all style files for the packages you have > specified there. Does this happen for you? Sorry I wrote that too fast. What I meant was the master file (subfile) uses the exam class. With the old auctex code the slave file did not know that the underlying class is the exam class. With your code it does. > Best, Arash ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
Uwe Brauer writes: > I just did. I restarted emacs, entered a subfiles with that path > structure, the style subfiles.el was not loaded. > > I evaluated your lisp code and voila: it works like charm, subfiles.el > is loaded and supports the editing as it should. Thanks for checking. I have a question, though: What do you mean with `subfiles.el is loaded'? That specific style from AUCTeX should be loaded anyway since you have \documentclass{subfiles} in your sub file document. The idea was that the parsed style file for your master document "../../main-file.tex", e.g. "../../auto/main-file.el", is loaded and consequently all style files for the packages you have specified there. Does this happen for you? Best, Arash ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
Hi Arash, > Hi Mosè, > Mosè Giordano writes: [...] > @Uwe: Can you try copy/paste this into you one of your sub files and > eval them? > \begin{verbatim} > (defun TeX-load-style (style) > "Search for and load each definition for STYLE in `TeX-style-path'." > (cond ((assoc style TeX-style-hook-list)) ; We already found it > ((string-match "\\`\\(.+[/\\]\\)\\([^/\\]*\\)\\'" style) ;Complex path > (let* ((dir (substring style (match-beginning 1) (match-end 1))) > (style (substring style (match-beginning 2) (match-end 2))) > (master-dir (if (stringp TeX-master) > (file-name-directory > (file-relative-name TeX-master)) > "./")) > (TeX-style-path (append (list (expand-file-name >TeX-auto-local dir) > (expand-file-name >TeX-auto-local master-dir) > (expand-file-name >TeX-style-local dir) > (expand-file-name >TeX-style-local master-dir)) > TeX-style-path))) > ;; (TeX-load-style style) > ;; start possible fix >(dolist (name TeX-style-path) >(TeX-load-style-file (expand-file-name style name))) > ;; end possible fix > )) > (t ;Relative path > ;; Insert empty list to mark the fact that we have searched. > (setq TeX-style-hook-list (cons (list style) TeX-style-hook-list)) > ;; Now check each element of the path > (dolist (name TeX-style-path) >(TeX-load-style-file (expand-file-name style name)) > (TeX-run-style-hooks > (file-name-sans-extension > (cadr (assoc "subfiles" LaTeX-provided-class-options > \end{verbatim} I just did. I restarted emacs, entered a subfiles with that path structure, the style subfiles.el was not loaded. I evaluated your lisp code and voila: it works like charm, subfiles.el is loaded and supports the editing as it should. Thanks very much This is indeed great! Uwe ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
Hi Mosè, Mosè Giordano writes: > 2017-02-15 9:19 GMT+01:00 Arash Esbati : >> what do you think about this small patch against subfiles.el: > > Actually in subfiles.el it should be sufficient to replace > `file-name-base' with `file-name-sans-extension', but I didn't have > the time to understand why `TeX-load-style' doesn't load it. I think the issue is in `TeX-load-style': --8<---cut here---start->8--- (defun TeX-load-style (style) "Search for and load each definition for STYLE in `TeX-style-path'." (cond ((assoc style TeX-style-hook-list)) ; We already found it ((string-match "\\`\\(.+[/\\]\\)\\([^/\\]*\\)\\'" style) ;Complex path (let* ((dir (substring style (match-beginning 1) (match-end 1))) (style (substring style (match-beginning 2) (match-end 2))) (master-dir (if (stringp TeX-master) (file-name-directory (file-relative-name TeX-master)) "./")) (TeX-style-path (append (list (expand-file-name TeX-auto-local dir) (expand-file-name TeX-auto-local master-dir) (expand-file-name TeX-style-local dir) (expand-file-name TeX-style-local master-dir)) TeX-style-path))) (TeX-load-style style))) (t ;Relative path ;; Insert empty list to mark the fact that we have searched. (setq TeX-style-hook-list (cons (list style) TeX-style-hook-list)) ;; Now check each element of the path (dolist (name TeX-style-path) (TeX-load-style-file (expand-file-name style name)) --8<---cut here---end--->8--- When invoked as (TeX-load-style "../../main-file.tex") from `TeX-run-style-hooks' (with `file-name-sans-extension' as you suggested, of course), `TeX-load-style' sees a complex path and starts the second condition. But then, it makes a recursive call to (TeX-load-style style) which is (TeX-load-style "main-file"). Now the t condition is called and (TeX-load-style-file ...) does not find any auto generated file it standard style path since the additions of the first run are lost. I think this can be fixed by adding (dolist (name TeX-style-path) (TeX-load-style-file (expand-file-name style name))) to second condition as well. @Uwe: Can you try copy/paste this into you one of your sub files and eval them? --8<---cut here---start->8--- \begin{verbatim} (defun TeX-load-style (style) "Search for and load each definition for STYLE in `TeX-style-path'." (cond ((assoc style TeX-style-hook-list)) ; We already found it ((string-match "\\`\\(.+[/\\]\\)\\([^/\\]*\\)\\'" style) ;Complex path (let* ((dir (substring style (match-beginning 1) (match-end 1))) (style (substring style (match-beginning 2) (match-end 2))) (master-dir (if (stringp TeX-master) (file-name-directory (file-relative-name TeX-master)) "./")) (TeX-style-path (append (list (expand-file-name TeX-auto-local dir) (expand-file-name TeX-auto-local master-dir) (expand-file-name TeX-style-local dir) (expand-file-name TeX-style-local master-dir)) TeX-style-path))) ;; (TeX-load-style style) ;; start possible fix (dolist (name TeX-style-path) (TeX-load-style-file (expand-file-name style name))) ;; end possible fix )) (t ;Relative path ;; Insert empty list to mark the fact that we have searched. (setq TeX-style-hook-list (cons (list style) TeX-style-hook-list)) ;; Now check each element of the path (dolist (name TeX-style-path) (TeX-load-style-file (expand-file-name style name)) (TeX-run-style-hooks (file-name-sans-extension (cadr (assoc "subfiles" LaTeX-provided-class-options \end{verbatim} --8<---cut here---end--->8--- Best, Arash ___ auctex-devel mailing list auctex-d
Re: [AUCTeX-devel] Small patch for subfiles.el
Hi Arash, 2017-02-15 9:19 GMT+01:00 Arash Esbati : > what do you think about this small patch against subfiles.el: Actually in subfiles.el it should be sufficient to replace `file-name-base' with `file-name-sans-extension', but I didn't have the time to understand why `TeX-load-style' doesn't load it. Bye, Mosè ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
> Uwe Brauer writes: > Ok, understood, but I'm far away from that. So you either have better hardware than I do, or something is strange in my setting. I still don't understand why auctex scans \documentclass[../main.tex]{subfiles} But not. \documentclass[../../main.tex]{subfiles} > I've never used ImageMagick feature, but the way I get it you have to > use a property within `create-image'. Check its doc-string for more. Ok but this sounds like writing a new minor mode, which uses that function. Uwe ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
Uwe Brauer writes: > Well I have a lenovo X200s with a 200 SSD and it almost needs 1 minute > to complete. I call that slow. Ok, understood, but I'm far away from that. >> Reg. scaling images, you could try to load your images in Emacs with >> ImageMagick support; I think it can scale[1]. > > Hm I have > Configured features: > XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS > NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB > TOOLKIT_SCROLL_BARS GTK3 X11 > > But then suppose I have > > \includegraphics{myimg.jpg} > > Iimage.el displays the image but how am I suppose to scale that? I mean > where I am suppose to add the magic keywords (:width width, :height > height) without breaking latex syntax? I've never used ImageMagick feature, but the way I get it you have to use a property within `create-image'. Check its doc-string for more. Best, Arash ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
> Uwe Brauer writes: > Thanks for your checking. I'm not sure what you mean with slow. I > tried the function for a file in a directory with 60 .tex files (260 > files total) and the completion was almost without any delay (and my HD > setup is not fast). Well I have a lenovo X200s with a 200 SSD and it almost needs 1 minute to complete. I call that slow. > I'm afraid there is not much checking; the argument of interest is > PREDICATE for Emacs and HISTORY for XEmacs (IIRC). I'm happy as long as > the function does not throw an error on XEmacs. > Reg. scaling images, you could try to load your images in Emacs with > ImageMagick support; I think it can scale[1]. Hm I have Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 But then suppose I have \includegraphics{myimg.jpg} Iimage.el displays the image but how am I suppose to scale that? I mean where I am suppose to add the magic keywords (:width width, :height height) without breaking latex syntax? > Best, Arash > Footnotes: > [1] https://www.gnu.org/software/emacs/manual/html_node/elisp/ImageMagick-Images.html ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
Uwe Brauer writes: "Arash" == Arash Esbati writes: >> >> With this, Emacs will ask with completion for the main file to be >> included in the optional argument of \documentclass in a subfile and >> returns it relative to master file (usually the subfile itself). > > I checked it with GNU emacs and it is nice, on the other hand I admit > that at least on my laptop, this function is quite slow, that is why I > usually use templates when creating a new document. Thanks for your checking. I'm not sure what you mean with slow. I tried the function for a file in a directory with 60 .tex files (260 files total) and the completion was almost without any delay (and my HD setup is not fast). >> Drawback: This does not work with XEmacs. > > Ok, I have in the coming month very little time to look into that, so I > stick with GNU emacs. I'm afraid there is not much checking; the argument of interest is PREDICATE for Emacs and HISTORY for XEmacs (IIRC). I'm happy as long as the function does not throw an error on XEmacs. > I could use preview-latex to display those in GNU emacs but it is not > the same, and iimage mode, a minor mode, which displays images in the > buffer, does not allow to rescale images. Reg. scaling images, you could try to load your images in Emacs with ImageMagick support; I think it can scale[1]. Best, Arash Footnotes: [1] https://www.gnu.org/software/emacs/manual/html_node/elisp/ImageMagick-Images.html ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
>>> "Arash" == Arash Esbati writes: Hi Arash > Hi Uwe, > what do you think about this small patch against subfiles.el: > diff --git a/style/subfiles.el b/style/subfiles.el > index 40993157..52bc7c31 100644 > --- a/style/subfiles.el > +++ b/style/subfiles.el > @@ -36,6 +36,15 @@ > (defvar LaTeX-subfiles-package-options nil >"Package options for the subfiles package.") > +(defun LaTeX-subfiles-class-options () > + "Return name of the main file relative to current subfile." > + (file-relative-name > + (read-file-name > +"Main file: " nil nil nil nil > +(lambda (texfiles) > + (string-match "\\.tex$" texfiles))) > + (TeX-master-directory))) > + > (TeX-add-style-hook > "subfiles" > (lambda () > With this, Emacs will ask with completion for the main file to be > included in the optional argument of \documentclass in a subfile and > returns it relative to master file (usually the subfile itself). I checked it with GNU emacs and it is nice, on the other hand I admit that at least on my laptop, this function is quite slow, that is why I usually use templates when creating a new document. In any case thanks, and as far as I am concerned please commit. > Drawback: This does not work with XEmacs. Ok, I have in the coming month very little time to look into that, so I stick with GNU emacs. BTW right now I use Xemacs just when I need to display graphics via the x-symbol package. I could use preview-latex to display those in GNU emacs but it is not the same, and iimage mode, a minor mode, which displays images in the buffer, does not allow to rescale images. However it seems that not very many people are missing such a feature... Uwe ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel
Re: [AUCTeX-devel] Small patch for subfiles.el
>>> "Arash" == Arash Esbati writes: > Hi Uwe, > what do you think about this small patch against subfiles.el: Thanks I will try to test it tomorrow and report back. The idea looks very nice. Uwe ___ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel