Hi, there, That is interesting. Sorry for the confusion, this is the same
issue I have been trying to describe.

Yes, I have configured emacs to forward jump to okular, just like we can do
it with kdvi, here is the okular-search.el file I used for emacs to jump to
okular, actually I modified kdvi-search.el to achieved it. It works fine
except whenever it jump to the right place but auto-center the page, which
is quite annoying.

When we use emacs to jump to kdvi, the page horizontal position doesn't
change, but okular will always auto-center horizontally  the new page.

In addition, here is the lisp code I put in .emacs in order for it to do so:

;; start the server so that the inverse search works
(server-start)
(require 'okular-search)
(add-hook 'LaTeX-mode-hook (lambda () (local-set-key "\C-x\C-j"
'okular-jump-to-line)))
(add-hook 'tex-mode-hook (lambda () (local-set-key "\C-x\C-j"
'okular-jump-to-line)))

See both the okular-search.el file as well as the lines above.

Your help is greatly appreciated. Thanks a lot.

On Sat, Nov 21, 2009 at 12:18 PM, Luigi Toscano <luigi.tosc...@tiscali.it>wrote:

> Hi,
> I think that you are talking about two different things.
>
> Mark Altern wrote:
> > Sure, there is something like: < 5 of 34 > at the bottom of the page,
> > and when you click >, it turn to next page, but every time you click it
> > to turn to next page, it will auto-center the page.
> This is what all the viewers I tested do: kdvi, evince, acroread, xdvi
> (and okular, of course). When you change the page, the view changes to
> the upper-left corner of the chosen page. This is a consistent
> behaviour, I don't think it's worth to change that.
> But...
>
> > In most cases, the dvi file I am viewing is not-symmetric and it is
> > zoomed in as large as possible to fit my screen, thus the pages are NOT
> > centered. Then when I use emacs to forward jump from emacs to okular, it
> > will jump to the proper line in proper page, BUT it will auto-center the
> > page that makes the page land in the middle, which is of couse will
> > messed up its original hozinontal position.
> What is that "forward jump", exactly? Have you configured emacs to call
> okular and jump to the specified line? Can you provide us this
> configuration?
> I don't think that this is the same "issue" you described before,
> because as I told you, kdvi acts exactly like okular, in that case.
>
> Regards,
> --
> Luigi
> _______________________________________________
> Okular-devel mailing list
> Okular-devel@kde.org
> https://mail.kde.org/mailman/listinfo/okular-devel
>
;;; (X)Emacs frontend to forward search with kdvi. See the section on
;;; FORWARD SEARCH in the kdvi manual for more information on forward
;;; search, and for an explanation how to use this script. This script
;;; is a modified version of the script "xdvi-search.el" by Stefan
;;; Ulrich <ulr...@cis.uni-muenchen.de>, version 2000/03/13. The
;;; modifications were performed by Stefan Kebekus
;;; <kebe...@kde.org>. Tested with Emacs 20.7.1 and Xemacs 21.4.
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
;;; published by the Free Software Foundation; either version 2 of the
;;; License, or (at your option) any later version.
;;; 
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;; General Public License for more details.
;;; 
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
;;; 02110-1301, USA.
;;;
;;; Please report bugs or improvements, etc. via the "Report bug"-Menu
;;; of okular.
;;;

(defvar okular-script "okular"
  "*Name of start script for okular.")

(defun okular-jump-to-line ()
  "Call okular-script to perform a `forward search' for current file and line number.
See contents of okular-script for details.
If AucTeX is used, the value of TeX-master-file is used as filename
for the master .dvi file; else, the return value of okular-master-file-name
is used (which see)."
  (interactive)
  (save-excursion
    (save-restriction
      (widen)
      (beginning-of-line 1)
      (let* (;;; current line in file, as found in the documentation
	     ;;; of emacs. Slightly non-intuitive.
	     (current-line (format "%d" (+ 1 (count-lines (point-min) (point)))))
	     ;;; name of the `main' .tex file, which is also used as .dvi basename:
	     (master-file (expand-file-name (if (fboundp 'TeX-master-file)
					     (TeX-master-file t)
					   (okular-get-masterfile (okular-master-file-name)))))
	     ;;; .dvi file name:
	     (dvi-file (concat (file-name-sans-extension master-file) ".dvi"))
	     ;;; current source file name.
	     (filename (expand-file-name (buffer-file-name))))
	(start-process "okular"
		       "okular-output" "okular" ;;; src-args
		      ;;; args for -sourceposition:
		       "--unique" (concat "file:" dvi-file "#src:" current-line filename)
		       )))))

(defun okular-get-masterfile (file)
  "Small helper function for AucTeX compatibility.
Converts the special value t that TeX-master might be set to
into a real file name."
  (if (eq file t)
      (buffer-file-name)
    file))


(defun okular-master-file-name ()
  "Emulate AucTeX's TeX-master-file function.
Partly copied from tex.el's TeX-master-file and TeX-add-local-master."
  (if (boundp 'TeX-master)
      TeX-master
    (let ((master-file (read-file-name "Master file (default this file): ")))
      (if (y-or-n-p "Save info as local variable? ")
	  (progn
	    (goto-char (point-max))
	    (if (re-search-backward "^\\([^\n]+\\)Local Variables:" nil t)
		(let* ((prefix (if (match-beginning 1)
				   (buffer-substring (match-beginning 1) (match-end 1))
				 ""))
		      (start (point)))
		  (re-search-forward (regexp-quote (concat prefix "End:")) nil t)
		  (if (re-search-backward (regexp-quote (concat prefix "TeX-master")) start t)
		      ;;; if TeX-master line exists already, replace it
		      (progn
			(beginning-of-line 1)
			(kill-line 1))
		    (beginning-of-line 1))
		  (insert prefix "TeX-master: " (prin1-to-string master-file) "\n"))
	      (insert "\n%%% Local Variables: "
;;; mode is of little use without AucTeX ...
;;;		      "\n%%% mode: " (substring (symbol-name major-mode) 0 -5)
		      "\n%%% TeX-master: " (prin1-to-string master-file)
		      "\n%%% End: \n"))
	    (save-buffer)
	    (message "(local variables written.)"))
	(message "(nothing written.)"))
      (set (make-local-variable 'TeX-master) master-file))))


(provide 'okular-search)

_______________________________________________
Okular-devel mailing list
Okular-devel@kde.org
https://mail.kde.org/mailman/listinfo/okular-devel

Reply via email to