Problems with pdflatex in emacs org-export-as-pdf - macos

I have some problems with the emacs org-mode. When I use the command org-export-as-pdf in org-mode, I got the error:
/bin/bash: pdflatex: command not found [3 times]
I am a Mac OS X(10.7) user and the version of emacs is 24.2. I downloaded the Tex Live from the official website and it was installed at /usr/local/texlive. I knew the env variables of emacs shell is different from user's terminal, so I tried this command:
M-! $PATH
it printed:
/bin/bash: /usr/bin:/bin:/usr/sbin:/sbin: No such file or directory
then I typed some commands below:
$which pdflatex
/usr/texbin
$ln -s /usr/texbin/pdflatex /usr/bin
and then I turned back to emacs, and tried org-export-as-pdf again, the same problem still existed.
I am confused and I need your help ;-)

Add the pdflatex directory to the Emacs PATH environment variable, instead of the symbolic link, e.g. add this to ~/.emacs:
(setenv "PATH" (concat (getenv "PATH") ":/usr/texbin"))
and source it again with M-x load-file and type ~/.emacs. And now C-c C-e lp in Org-mode works:
PDF file produced.
(Cross-posted on Unix.StackExchange.)

Related

-bash: emacs.profile: command not found

I am trying to resolve this issue and trying to get it work. What are all the steps of the solution? I really don't know what to do on my Mac terminal
-bash: emacs.profile: command not found
What are you trying to accomplish? If you're trying to open a file named .profile with emacs you'll want to add a space between the command emacs and the file .profile:
$ emacs .profile
If you are typing emacs.profile you will get an error because you are mixing together the command emacs and the file you are trying to edit: .profile. Therefore the solution would be to add a space between them like someone suggested: $ emacs .profile.
On the other hand, if you are typing emacs .profile and you are still getting: -bash: emacs: command not found, this means that you haven't installed emacs yet and your system doesn't recognize that instruction.
Emacs is a very popular text editor and is widely used by technical users, but it is not installed by default.
Solution 1:
If you want to edit a file (in this case ~/.profile) you don't need emacs to do so, you could just use a normal text editor or a pre-installed text editor using your terminal like:
$ vi ~/.profile or $ nano ~/.profile
(Guide to use Vi/Vim text editors) (Guide to use Nano).
Solution 2:
If you want to install emacs to edit that file, you can do so using brew:
$ brew update
$ brew install emacs
And after that you can use:
$ emacs ~/.profile
You can find other ways to install emacs here.
Important Note:
One important thing to consider in this example, is that if you are trying to edit the .profile file (i.e. to set an exported environment variable) you should know that the name of the .profile file might vary from one Mac system to another. The name of this profile configuration file depends on the shell of your system, if you are using bash the name of this profile will be .bashrc or .bash_profile.
Before editing your profile file make sure what is the name of the profile file you are trying to edit. To do so, you can use:
$ cd $HOME
to go to the Home folder and then use:
$ ls -al
to see hidden files (These files starting with . are hidden files). You will find the profile file of your system there.

How to open emacs gui/ide from mac terminal?

I'm trying to open files up on emacs outside of the terminal. I prefer a gui/ide environment when I code instead of doing it through a terminal. I initially thought that typing emacs filename.py would open that file through Emacs.app, however it only allowed me to edit the file through the terminal. When this didn't work, I looked into editing the .profile and .emacs files in my home directory but this was to no avail.
Maybe this is more intuitive than what I've read but I can't seem to figure it out. Any help is appreciated.
Assuming you have Emacs installed from Homebrew like this:
brew install emacs --with-cocoa
Just type the following command to open Emacs.app from terminal:
open -a Emacs filename.py
If you want all files opened in the same frame, instead of new frames, put this into your .emacs file:
(setq ns-pop-up-frames nil)
The best way to open files in Emacs from the terminal is the emacsclient command, which will open the file in your existing Emacs app (preventing startup time). If you're on OSX and you installed Emacs through Homebrew, the emacsclient binary will already be set up. (In your Emacs config, you have to include (server-start) somewhere.)
If you actually want to spin up a new GUI app instance instead, you can set up your own shell script and put it in your PATH somewhere before the existing emacs binary. It sounds like you're using Homebrew, which sets up the emacs binary as the following shell script:
#!/bin/bash
/usr/local/Cellar/emacs/24.3/Emacs.app/Contents/MacOS/Emacs -nw "$#"
The -nw is what prevents Emacs from opening in GUI mode. You can make your own emacs shell script and leave out -nw:
#!/bin/bash
/usr/local/Cellar/emacs/24.3/Emacs.app/Contents/MacOS/Emacs "$#"
To do what you want, you'd need to find the location of the actual binary contained in Emacs.app, and use that as the command instead of emacs. Most likely, it's at
/path/to/Emacs.app/Contents/MacOS/Emacs
Which, if you have Emacs.app in your Applications folder, as would be typical, would be
/Applications/Emacs.app/Contents/MacOS/Emacs
To set it up with a shorter command to use, you could try adding to your .profile (I don't know what shell you use) the following line, or whatever equivalent it has for your shell (This works for bash and zsh, at least):
alias emacsgui='/Applications/Emacs.app/Contents/MacOS/Emacs'
The modern way to go about this is by installing Emacs using Homebrew Cask:
brew cask install emacs
Source: this comment by Homebrew project leader Mike McQuaid, which reads:
Cocoa support for Emacs will not be accepted. This is provided by brew cask install emacs.
One should link emacs to /Applications if not already done,
brew linkapps emacs
to link the emacs to symlink emacs installed in Cellar. Once symlinked, you can open emacs by
open -a emacs
as already pointed out by #katspaugh
brew doesn't have cask command anymore.
I used brew install emacs and I can find Emacs app installed in my application directory.
You can also head to https://emacsformacosx.com and download the .dmg file.

Weird character zsh in emacs terminal

When using the terminal in emacs (M-x term) under MacOS for some reason it always posts the characters 4m before every line in zsh and always prints 2 lines containing the user info such as
4m--(jesus#laptop:/dir)----
4m--(jesus#laptop:/dir)----
prompt>
It's more of an annoyance than anything but I was just wondering if there's a way to fix this. I also seem to have issues in Zsh in Mac OS emacs terminal mode when a lot of output is written to it it seems to reduce it all to one line and constantly overwrite the same line (may be related as the 4m is possibly just a special character that emacs is treating differently which can affect formatting).
If need be I can post my .zshrc and .emacs files.
You don't have eterm-color terminfo.
First, you try to add following S-exp in your configuration file and evaluate.
;; Use Emacs terminfo, not system terminfo
(setq system-uses-terminfo nil)
If problem is not resolved previous setting, you should create eterm-color terminfo
by using following command. (terminfo path may different from your system)
# If you use Cocoa Emacs or Carbon Emacs
tic -o ~/.terminfo /Applications/Emacs.app/Contents/Resources/etc/e/eterm-color.ti
I needed to set the following environment variables in my ~/.zshrc
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export TERM=xterm-256color
This installed eterm-color.ti for me on OSX Mavericks 10.9.5:
Upload eterm-color.ti to /tmp on the remote OSX server.
Run the command sudo tic -o /usr/share/terminfo /tmp/eterm-color.ti on the server.
In my case, this put a file eterm-color in the directory /usr/share/terminfo/65/

Mac os x: How to have makefile reference /Applications/application

OS Mac OS X 10.6.6
emacs 23.2.1
I'm currently trying to install magit on carbon emacs using their proposed make solution. I'm an almost complete makefile newby so I might be on the complete wrong path altogether.
Makefile displays:
%.elc: %.el
$(BATCH) --eval '(byte-compile-file "$<")'
which gets expanded to:
emacs -batch -q -no-site-file -eval "(setq load-path (cons (expand-file-name \".\") load-path))" --eval '(byte-compile-file "magit.el")'
What I do understand. However it comes back with:
Cannot open load file: subst-ksc
What after a bit of googling reveals some missing libraries. I also realized that the emacs referenced in the expanded command is pointing to /usr/bin/emacs which is one big file, I don't see the normal lisp / site-lisp / etc directories. I also know that my prefered emacs is carbon emacs located in /Application/Emacs.app which just opens when clicking on it, or alternatively, I can open it in with the terminal:
open /Application/MyApp.app
Finally the title question: How can I make Makefile using the Emacs.app on the applications directory? I hope someone here knows the answer, or can point me to alternatives.
regards,
Jeroen.
bash-3.2$ EMACSLOADPATH=/usr/share/emacs/22.1/site-lisp:/usr/share/emacs/22.1/lisp emacs - batch -eval '(print "hi")'
"hi"
bash-3.2$ emacs -batch -eval '(print "hi")'
Cannot open load file: subst-ksc
bash-3.2$
bash-3.2$ emacs -batch -eval '(print emacs-version)'
Cannot open load file: subst-ksc
bash-3.2$ unset EMACSLOADPATH
bash-3.2$ emacs -batch -eval '(print emacs-version)'
"22.1.1"
I had the same error Cannot open load file: subst-ksc on OS X Maverick running
cask exec emacs --no-site-file --no-site-lisp --batch \
\
-f batch-byte-compile projectile.el
I solved it with the method given here.
Replace the /usr/bin/emacs file by the following script:
#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "$#"
With that manner the emacs command will run your actual Emacs.

pdflatex command not working in Emacs terminal mode

I have some problem with the Emacs terminal mode.
I'm a mac user and I use Emacs downloaded from emacsformacosx.com; I installed also ESS and AucTex.
I work with R, LaTex, Sweve and, I menage all with Emacs. When I want to compile the Sweave file I open the terminal and I use the "R CMD Sweave myfile.Rnw" command to generate a myfile.tex file. After this I use "pdflatex myfile.tex" command, to compile the LaTex file.
All these command work well if used in the terminal application of osx but, the pdflatex command doesn't work if I use the Emacs teminal mode:
bash: pdflatex: command not found
Do you have any suggestion?
EDIT
Thanks for your suggestion, I resolved my problem adding to my .emacs this:
(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell
(replace-regexp-in-string "[[:space:]\n]*$" ""
(shell-command-to-string "$SHELL -l -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))
(when (equal system-type 'darwin) (set-exec-path-from-shell-PATH))
I found it at link text
Best
Riccardo
On OS X, environment variables for GUI programs are set in ~/.MacOSX/environment.plist. There are many Emacs specific work arounds like using (setenv "PATH" (shell-command-to-string "echo -n $PATH")) which you can find scattered across Stack Overflow and the internet in general.

Resources