Re: [O] LaTeX export: Keep point position in TeX file
Michael Bach pha...@gmail.com writes: Eric S Fraga e.fr...@ucl.ac.uk writes: If so, I suggest you could achieve what you want by using the org-export-* hooks to, for instance, save current position before export and then jump to that position after export? Maybe org-export-first-hook and org-export-latex-final-hook could be used? Thanks for your thoughts on this and sorry for being late to reply. I No problem! stumbled upon your reply and have tried it today with this: [...] The switching to latex file works, but `(goto-char temppoint)' does not - for a reason I do not understand. The only benefit of this is that I do not understand either. Putting in some (message ...) lines, it is trying to (goto-char ...) to the right place in the buffer but that goto doesn't seem to have any effect. Have you looked at the code in org that actually invokes that hook to see if maybe position is being changed afterwards? -- : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.90.1 : using Org-mode version 7.8.03 (release_7.8.03.206.g10b06)
Re: [O] LaTeX export: Keep point position in TeX file
Eric S Fraga e.fr...@ucl.ac.uk writes: If so, I suggest you could achieve what you want by using the org-export-* hooks to, for instance, save current position before export and then jump to that position after export? Maybe org-export-first-hook and org-export-latex-final-hook could be used? Thanks for your thoughts on this and sorry for being late to reply. I stumbled upon your reply and have tried it today with this: --8---cut here---start-8--- (defun my-org-latex-export-save-point () (interactive) (let ((latexfile (concat (file-name-sans-extension (buffer-name)) .tex)) (orgfile (buffer-name))) (if (get-buffer latexfile) (save-excursion (set-buffer latexfile) (setq temppoint (point))) (message Open exported LaTeX file to save point position --8---cut here---end---8--- `(interactive)' is only for testing purposes. Saving of point in .tex file under `temppoint' works this way. I tried further restoring point but failed. For reference: --8---cut here---start-8--- (defun my-org-latex-export-restore-point () (interactive) (let ((latexfile (concat (file-name-sans-extension (buffer-name)) .tex)) (orgfile (concat (file-name-sans-extension (buffer-name)) .org))) (progn (switch-to-buffer-other-frame (get-buffer latexfile)) (goto-char temppoint --8---cut here---end---8--- The switching to latex file works, but `(goto-char temppoint)' does not - for a reason I do not understand. The only benefit of this is that after export, emacs switches to the latex file automatically, which may or may not be wanted (in my case, it is). The last thing is to bind the functions to the correct hooks. I found this worked: --8---cut here---start-8--- (add-hook 'org-export-latex-after-initial-vars-hook 'my-org-latex-export-save-point) (add-hook 'org-export-latex-after-save-hook 'my-org-latex-export-restore-point) --8---cut here---end---8--- Untried and obviously untested! And likely beyond my elisp capabilities so I'd be very keen on seeing a solution. This behaviour has also bothered me (well, very minor irritation) for a long time as I often export to latex when debugging the export to PDF. It is also a minor irritation to me. And even if I could get my solution to work as intended, this approach only helps for minor edits, since the org-export could insert arbitrarily many new lines into the latex file, making the restore by previous point position rather useless. What would be needed is a context sensitive position check which can check for environments and contents simultaneously. Just guessing and thinking aloud here. A solution by hobby-elispers like me will be necessarily cumbersome, but maybe someone more skilled can pick up the scraps and make it work better :-) Best, Michael
[O] LaTeX export: Keep point position in TeX file
Hello everyone, The way I am now doing LaTeX export is that I have the exported tex buffer below the org buffer. When I do an export via `C-c C-e l' the .tex buffer gets updated, but point jumps to beginning of buffer instead of staying where it was. (How) Can I changed that so point stays near where it was before I exported again? Best Regards, Michael
Re: [O] LaTeX export: Keep point position in TeX file
Michael Bach pha...@gmail.com writes: Hello everyone, The way I am now doing LaTeX export is that I have the exported tex buffer below the org buffer. When I do an export via `C-c C-e l' the .tex buffer gets updated, but point jumps to beginning of buffer instead of staying where it was. (How) Can I changed that so point stays near where it was before I exported again? Best Regards, Michael I think this behaviour arises because the exporter exports to a buffer which it first empties. So the behaviour you see is very different from when Emacs reverts a buffer when the file changes out from under it. If so, I suggest you could achieve what you want by using the org-export-* hooks to, for instance, save current position before export and then jump to that position after export? Maybe org-export-first-hook and org-export-latex-final-hook could be used? Untried and obviously untested! And likely beyond my elisp capabilities so I'd be very keen on seeing a solution. This behaviour has also bothered me (well, very minor irritation) for a long time as I often export to latex when debugging the export to PDF. HTH, eric -- : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.92.1 : using Org-mode version 7.8.03 (release_7.8.03.106.gc835)