py-python-command ignored - emacs

I'm using python-mode 6.0.1 on OS X, emacs 23.3 (http://emacsformacosx.com/ version).
I'm trying to get C-c C-c to default to python 3.
I have the following in my .emacs:
(setq py-python-command "/usr/local/bin/python3")
And when I run C-h b py-python-command, it tells me the value is that (correctly).
However, running C-c C-c still opens 2.7.2.
I also tried adding:
(setq py-which-shell "/usr/local/bin/python3")
as suggested here: Both Python 2 and 3 in Emacs, but that doesn't change anything (py-which-shell does get changed, but it still launches 2.7.2).
Any ideas?

Try adding the following code to your Emacs init file:
(add-hook 'python-mode-hook
(lambda ()
(setq py-python-command "python3")
(setq py-default-interpreter "python3")))

py-default-interpreter for now is an alias only, delivered for backward compatibility
You might have encountered a bug.
Please file a report giving some example code at
https://bugs.launchpad.net/python-mode
Should the buffer code contain a shebang specifying pythonVERSION , than this takes precedence over default setting.
You may enforce executing buffer through specific pythonVERSION by calling
a command of class py-execute-buffer-pythonVERSION
See menu PyExec, entry Execute buffer ...

Related

emacs init file on MS Windows

There's a huge literature on the topic, but, nevertheless, I cannot get this done.
My ultimate goal is to work with fstar on Microsoft Windows.
C-x C-f resolves ~ as C:/Users/myname which is in line with my HOME environment variable in the Environmental variables Windows section.
(expand-file-name user-emacs-directory), as described here yields, C:/Users/myname/.emacs.d/
In C:/Users/myname/.emacs.d/ I have placed .emacs.el and init.el with the suggested script:
(require 'package) (add-to-list 'package-archives '("melpa" .
"http://melpa.org/packages/") t) (package-initialize)
However M-x returns undefined, no matter if I start Emacs with or without the -q flag (see here). My "Messages" buffer is empty".
A couple of things you could try:
Check the value of the variable user-init-file (use C-h v). That should tell you if Emacs loads the file you want it to load. If you started Emacs with the -q option, the value of this variable should be nil.
The error M-x is undefined can be caused by rebinding the Escape key. (That's because pressing a key while holding down the "Meta" key is equivalent to first pressing Escape and then the key in question.) Is there something in the init file that might cause this to happen?
Try starting Emacs with -Q instead of -q. This makes Emacs skip "site-wide" init files. I can't really think of a reason why your system would have any of those, but it might be worth ruling this out.
You could edit your question and include your entire init file (surround it with ``` on a line by itself), so we could have a look.

Org-babel-execute-src-block: Wrong type argument: listp, "https://elpa.gnu.org/packages/"

In an org file, C-c C-c in the following block
#+begin_src emacs-lisp
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")))
#+end_src
I get an error, in the echo area it displays: wrong type argument : listp, as shown in the title of the question.
But C-h v package-archives RET shows that the code is actually executed, I also tried something like
#+begin src emacs-lisp
(+ 1 1)
#+end src
and it runs correctly, so only when the code contains a associate list the problem persist, I've also tried with emacs -Q and only load the org-babel and ob-emacs-lisp lib, it behaves the same.
Actually update org-mode to the newest version solve the problem, just make sure you delete /usr/local/share/emacs/lisp/org and install via package-install.

Enabling whitespace mode on emacs

I'm trying to enable whitespace mode but it doesn't seem to be working for me.
I've added the whitespace.el file to my .emacs.d/ directory.
I added the following lines to me .emacs file:
(add-hook 'before-save-hook 'whitespace-cleanup)
(add-hook 'before-save-hook (lambda() (delete-trailing-whitespace)))
(require 'whitespace)
I did the following in the whitespace.el file:
M-x byte-compile-file <path to whitespace.el>
I tried executing the following command from any random text in emacs (e.g.: test.c):
M-x whitespace-toggle-options RET
But I just get a message saying [No match]
What am I missing?
Also, will I have to type in a command to enable the whitespace-mode every time I use emacs?
whitespace.el has been included in Emacs for quite a while. Unless you have a very old version, you shouldn't need to manually put it anywhere, or do anything particularly special to use it.
whitespace-toggle-options probably isn't the function you want to use. Instead, try whitespace-mode:
Toggle whitespace visualization (Whitespace mode).
With a prefix argument ARG, enable Whitespace mode if ARG is
positive, and disable it otherwise. If called from Lisp, enable
the mode if ARG is omitted or nil.
If you want to enable it by default, add
(global-whitespace-mode)
to your init file.

Add a TeX symbol in the Emacs init file

I am trying to add the following code to my .emacs init file:
(TeX-add-symbols '("eqref" TeX-arg-ref))
But I cannot get it to work. I get the following error when running emacs t.tex (t.tex is here a sample text file) from the command line:
Warning (initialization): An error occurred while loading `.emacs':
Symbol's function definition is void: TeX-add-symbols
I am using GNU Emacs version 23.3.1 on Ubuntu 12.04. My .emacs init file looks like
(setq TeX-auto-parse t)
(setq TeX-electric-escape t)
(setq reftex-label-alist '((nil ?e nil "~\\eqref{%s}" nil nil)))
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(TeX-add-symbols '("eqref" TeX-arg-ref))
If I enter ESC-: (i.e. running the command eval-expression) and enter
(TeX-add-symbols '("eqref" TeX-arg-ref)) at the prompt it works fine. (That is after running this, I can enter \eqref in the buffer and it works as expected.. But this is not a good solution, having to enter this code manually each time I edit a file.. That is the reason why I try to set it up in the .emacs file..)
Background information for this question:
I have a problem with using the AucTeX style amsmath.el.. it seems that it is not loaded properly on my machine.. For more information, see Using \eqref with RefTeX.
You have to evaluate the code after LaTeX-mode is activated, otherwise you get the error Symbol's function definition is void: TeX-add-symbols. You can add that function to the hook of LaTeX-mode. In order to override possible other eqref macro definitions, you should add a dummy (ignore) to the definition of the macro. This code, in your .emacs, does the trick:
(add-hook 'LaTeX-mode-hook
'(lambda ()
(TeX-add-symbols '("eqref" TeX-arg-ref (ignore)))))

I want to run the cygwin bash shell from native windows emacs app

I have followed instructions from How can I run Cygwin Bash Shell from within Emacs? this question and I have gone further and added the (setq explicit-bash-args '("--login" "-i")) command, however emacs continues to only display the dos prompt when I type M-x shell. In summery my .emacs file looks like this:
(defun cygwin-shell ()
"Run cygwin bash in shell mode."
(interactive)
(let ((explicit-shell-file-name "C:/cygwin/bin/bash"))
(call-interactively 'shell)))
(setq explicit-bash-args '("--login" "-i"))`
Please be gentle with the answers as I am right at the bottom of the famous vertical emacs learning curve!
If you implemented the answer from that question, note that you have to do M-x cygwin-shell to start bash. If you want to use it for every M-x shell you need to call
(setq explicit-shell-file-name "C:/cygwin/bin/bash")
Since you stated that you are learning, here's a few tips when trying this out.
type C-x C-f ~/.emacs to open your .emacs file in your user path.
Enter your function above at the end
M-x load-file [RET] .emacs: loads the buffer (no need to restart emacs)
C-h a: If you are interested in some specific action, you can look it up
C-h v [RET] variable: can inspect the variable, check the value of explicit-bash-args for instance
And, btw, I'm not sure what the "--login -i" does, but someone stated in a comment that you should have that so "ls" would work. If you have your cygwin bin path in your PATH environment variable, bash will find ls anyway. No need to escape the path variable either, this is handled by bash (do an echo $PATH in bash when you get it working and you'll see).