Emacs uses dvi2tty instead of evince to open dvi - emacs

I started to use emacs for LateX editing again. Back in the days, it was configured automatically that C-c C-f would open the corresponding *.dvi file with evince. With the latest version of emacs, it does not do the same. Is there a way to open the doc with evince? (I am sure there is a way. It is emacs afterall).
Thanks!

I use this code with auctex-mode:
;; use evince for dvi and pdf viewer
;; evince-dvi backend should be installed
(setq TeX-view-program-selection
'((output-dvi "DVI Viewer")
(output-pdf "PDF Viewer")
(output-html "Google Chrome")))
(setq TeX-view-program-list
'(("DVI Viewer" "evince %o")
("PDF Viewer" "evince %o")
("Google Chrome" "google-chrome %o")))
You didn't mention if you're using auctex-mode or the old latex-mode that comes bundled with Emacs.

Depending on whether you are using AUCTeX or emacs' default LaTeX mode there are different configuration options to set this. I would suggest you have a look at them with customize-browse since the config strings can be pretty dense.
With AUCTeX
Browse to Emacs > Wp > Tex > AUCTeX > Tex Command > TeX View > TeX View Program Selection. Change the output-dvi viewer.
Plain LaTeX mode
Browser to Emacs > Wp > Tex > Tex View > Tex Dvi View Command.
Also, instead of directly hardcoding evince I would suggest putting xdg-open there and configuring your preferred dvi-viewer in your desktop environment. Then you need to worry about only one place to configure this in the future.

I had the same problem even with the correct settings for view commands. I had started the Emacs daemon from a shell inside screen. I then connected to the server with emacsclient using an X window. AucTeX checks two settings to see if you're using a window system and both are nil or undefined (the $DISPLAY variable and (window-system)) inside screen where I started the server.
So in my case, starting the Emacs daemon from a shell running in an X window solved the problem.
I guess it would help if AucTeX checked the variables for each Emacs frame separately because it shouldn't matter where the server was started but what kind of client (tty or X) you use AucTeX in.

Related

emacs 27.1 for windows 10 org mode not working during first load (Shell command succeeded with no output)

In Windows 10, Emacs 26.3 with inbuilt org version 9.1.9 is working fine (Packaged binaries). Recently I tried Emacs 27.1. with inbuilt org version 9.3. While loading .org files for first time, I get the message (Shell command succeeded with no output) and org files are not rendered at all. To render it, I have to use M-x org-mode or reload the file in the buffer again. I tried to run without loading .emacs.d folder packages. The issue persists. It means, it has nothing to do with already installed other packages. I also tried with latest org version 9.3.7 and and also tried with emacs -Q. Still the issue persists. Any solutions?
I know I'm very late, but found in Jeffs words:
Evil remaps C-i to evil-jump-forward to emulate Vim’s jump lists feature2, which overwrites the default mapping for the TAB key in Org mode.
To fix the tab key’s functionality in Org mode, sacrifice Evil’s C-i backward jumping by turning it off in your configuration with the evil-want-C-i-jump option.
So to solve, just edit your init.el to look like this:
;; Install Evil and disable C-i to jump forward to restore TAB functionality in Org mode.
(use-package evil
:init (setq evil-want-C-i-jump nil)
:config (evil-mode))
source: https://jeffkreeftmeijer.com/emacs-evil-org-tab/

Emacs24 , org-mode, can't find `latex'(needed to convert LaTeX fragments fo images)

I want to use the command C-c C-x C-l to preview latex code in org-mode. Since the emacs-nox cannot do this, I tried apt-get install emacs24. However, after I have installed the emacs24 with GUI, I get an error like
can't find \`latex'(needed to convert LaTeX fragments to images)
I have installed texlive2016, and I can latex *.tex in shell command.
I added the /paht/to/latex to .emacs, but it don't work well.
Adding the following to my init.el makes it work:
;; Making emacs find latex (so that C-c C-x C-l works on orgmode)
(setenv "PATH" (concat ":/Library/TeX/texbin/" (getenv "PATH")))
(add-to-list 'exec-path "/Library/TeX/texbin/")
It is not a very pretty solution, but it does the job and is very easy to modify and understand.
This solution worked on a Mac running macOS Sierra and Emacs v25.1.
My crystal ball tells me that the problem is that you're not starting the GUI Emacs from a terminal, so it can't inherit your $PATH settings. See for example https://emacs.stackexchange.com/questions/10722/ (that question is within OSX, but the same problem appears in other systems).
Apparently you can set env-vars globally (so that they affect all applications, including those started directly from the GUI) in ~/.pam_environment (that's for GNU/Linux systems). Note that this is only consulted when you login, so you need to logout+login for changes to take effect.

How do I control emacs from a terminal?

I'm trying to drive emacs on OSX using Dragon Naturally Speaking running inside a Windows VM. Rather than running emacs in the VM, I'd like to drive an emacs (built from the HEAD of the repository) already running on the mac side of things. So, after a hunt through the emacs lisp manual I came up with the following snippets of lisp (currently running from the scratch buffer while I work stuff out):
;; This part is run from an emacsclient -t session
(defvar slave-frame last-event-frame)
;; and this is run in a GUI frame
(defadvice handle-switch-frame (after update-slave-redirect-advice activate)
(unless (eq last-event-frame slave-frame)
(redirect-frame-focus slave-frame last-event-frame)))
And all is well. I type into the terminal window, displaying buffer A and my typing appears in the GUI frame busily dsplaying buffer B. Great. Until I do C-x C-f or any other command that needs the minibuffer, at which point I get the error Terminal 1 is locked, cannot read from it.
I'm I barking up the wrong tree here, or is there a way to make redirect-frame-focus work nicely with commands that use the minibuffer?
Piers,
What behavior do you want, redirection to a minibuffer on the (Windows) client or a minibuffer on the server? Also, what version/flavor of emacs are you using?

How can i paste the selected region outside of emacs?

I am using Mac OS and emacs -nw (the terminal mode).
I don't know how can I paste things (having been implemented by M-w in emacs -nw) outside the emacs.
I know that the emacs -ns can do it.
Searching the internet and the command C-h b, i find out that method, but it didn't work out.
(setq x-select-enable-clipboard t)
(setq interprogram-cut-function 'x-select-text)
I don't know much about the argument of interprogram-cut-function.
Where does the x-select-text come from and what does it mean?
If you are using Ubuntu 12.04 or Fedora 21, there are a couple of options to make this work.
First you need to install xclip
sudo apt-get install xclip
First Option: For Emacs 24
If you are using emacs24 you can install from the list of packages
M-x package-list-packages
Select
xclip //mine was version 1.3
In your .emacs add:
(xclip-mode 1)
Second Option. For emacs before version 24
Install xclip.el:
Integrating Emacs with the X11 Clipboard in Linux
Third Option. Using #Nicholas Riley code shown in the answer
To use the code in the answer you need
pbcopy / pbpaste in Ubuntu (command line clipboard)
x-select-text is only used if you're running Emacs in a GUI. (Emacs maps the Mac/Windows pasteboard/clipboard APIs to the X11 model, hence the name). You can always use C-h f to find out more about a function like this one and view its definition if it's written in elisp.
On the Mac, there is no concept of CLIPBOARD versus PRIMARY selections, so there is no point in setting x-select-enable-clipboard.
The whole point of running emacs -nw is that it doesn't interact with the windowing system. Why use Emacs in a terminal when there are plenty of graphical Emacsen that work very nicely on the Mac?
That said, if you really wanted to hook up terminal Emacs to the Mac pasteboard, you could do something like this:
(setq interprogram-cut-function
(lambda (text &optional push)
(let* ((process-connection-type nil)
(pbproxy (start-process "pbcopy" "pbcopy" "/usr/bin/pbcopy")))
(process-send-string pbproxy text)
(process-send-eof pbproxy))))
If you want a way to place the contents of the emacs region onto the clipboard only sometimes, as opposed to every time you do an emacs yank (which causes the clipboard contents the be overwitten all the time), you should check this answer to a related question:
https://stackoverflow.com/a/19625063/3363328
I found that it solved my problem much better than setting xclip mode.

Emacs 23.1 and Mac OS X problem with files drag and drop

I've just compiled and installed emacs 23.1 on my mac. It's running Leopard 10.5.8. And I've noticed that dragging and dropping does not work correctly (as it used to work with emacs 22). Now when dragging a file to the emacs icon on the dock, Emacs will start with two windows (frames in its terminology), one showing the startup screen and the other with the contents of the file. I've tried to get rid of this behaviour and I've set 'inhibit-startup-screen' option to t. But that only helped with this problem.
The other problem that I have is that when dragging a file onto a running emacs window, it justs shows the contents of the file in the existing buffer, instead of opening a new buffer (named the same as the file).
Any help with that?
I've compiled emacs myself using guidlines from this page:
link text
Also I've noticed that this version of Emacs has been rather flaky - it crashed a few times. I do not remember such situations when using previous versions. Any help will be highly appreciated.
Just to have the information regarding this problem more complete - there's a whole page in emacs info dedicated to Mac OS X builds.
Here's the link to web version: emacs info about ns events
Also I've found that when using Emacs 23 as an external editor for XCode, each file gets opened in a different frame (window). To fix this, just add:
(setq ns-pop-up-frames nil)
to your .emacs file
Putting the following in your .emacs file will help. You will either have to restart Emacs or evaluate the code.
(define-key global-map [ns-drag-file] 'my-ns-open-files)
(defun my-ns-open-files ()
"Open files in the list `ns-input-file'."
(interactive)
(mapc 'find-file ns-input-file)
(setq ns-input-file nil))