11
votes
Exporting highlighted source code to pdf in Org-Mode
Hey this answer solved my similar problem. A bit late but I had the same issue today.
As mentioned, I add the following code snipped to my .spacemacs/.emacs config:
(require 'org)
(require 'ox-latex)...
11
votes
Accepted
How to highlight in different colors for variables inside `fstring` on python-mode
I think this will do it for Emacs versions < 27.1
(require 'python)
(setq python-font-lock-keywords
(append python-font-lock-keywords
'(;; this is the full string.
;; group ...
9
votes
Accepted
Python in org babel will not work
Ah. It's entirely possible python is actually working; depending on exactly how you've set up your python src blocks in Org, you may simply not be getting any results. You may know this already, but ...
9
votes
Accepted
Org mode python code block with session does not return a result
The python implementation in Org babel has a couple of long-standing problems:
If you specify :results value, then the body is implicitly wrapped in a function and you have to add a return statement ...
8
votes
Get pandas data-frame as a table in org-babel
Update for people reading this in 2020
You can now use tabulate Python package and write:
#+begin_src python :results value raw :return tabulate(df, headers=df.columns, tablefmt='orgtbl')
from ...
8
votes
Using conda environments in emacs
I have recently incorporated Anaconda into my python development and was having similar problems setting up Emacs + flycheck + linters. This answer got me up and running, but I've modified it, since ...
8
votes
Specifying python version in run-python
Put (setq python-shell-interpreter "python3") into your .emacs.
8
votes
Saving Python matplotlib figures with source-code blocks
I'm a little late but I just figured out a pretty neat way to do this using :file and without using :var.
As the other anwser already pointed out plt.show() doesn't produce output.
However you can use ...
8
votes
Accepted
How do I suppress messages in the echo area (e.g. `Fill column set to 80 (was 80)`)?
@NickD answered the question well. But you can also do this, just to inhibit showing messages for set-fill-column:
(add-hook 'python-mode-hook
(lambda ()
(setq indent-tabs-mode ...
7
votes
How do you create a robust Python IDE with Emacs (as the Text editor)
I use purpose-mode. This allows you to define a pretty robust environment.
Using elpy, pydoc, and neotree I have a pretty robust environment (in the sense that windows don't do strange things at ...
7
votes
Accepted
org-src-mode send commands to repl in named python :session, not *Python*
This is really hidden and (to my knowledge) not documented so caveat emptor …
At the very end of org-edit-src-code I found the following snippet:
(let ((edit-prep-func (intern (concat "org-babel-...
7
votes
Dedicated Python Shell?
OK, so I figured this out (thanks largely to this answer). Now, rather than simply typing C-c C-p, I use C-u C-c C-p to get the options of specifying the Python command I want, and to select a ...
7
votes
Accepted
How to gnuplot a referred evaluated table in org-babel?
There are 2 Problems in your code.
1st: Replace the obsolete srcname with name. (Some more background is given below.)
2nd: Do not refer to the raw result data of the python block as gnuplot block ...
6
votes
Running ipython remotely
@serv-inc answear is the best approach here:
(setq python-shell-interpreter "ssh yourhost ipython"
python-shell-interpreter-args "--simple-prompt -i")
but it will still fail with the error:
...
6
votes
‘python-shell-interpreter’ doesn’t seem to support readline
The links you were reading are mostly about macOS and/or Emacs 25.1 and earlier.
Unfortunately, the "native" completion won't work under Windows, as it lacks PTYs.
So you should do (setq python-...
6
votes
Accepted
How to control emacs externally?
I used the TCP approach suggested by @wvxvw in the comments. I'm starting a TCP server inside emacs, which, when receiving a package, will eval it as elisp code. I found a piece of code for the TCP ...
6
votes
Accepted
How to syntax highlight Python f-strings so {...} uses regular code colors?
FWIW, I just pushed support for "proper" highlighting of f-strings in Emacs's master branch, so it will be available in Emacs-28 when that gets released (and is available in GNU ELPA's ...
6
votes
Accepted
Can’t guess python-indent-offset - delete warning when local file variable
The error message is controlled by the python-indent-guess-indent-offset-verbose variable.
Since the variable is file-local, you should be able to disable it globally if you put the following in your ...
6
votes
Accepted
python interpreter within emacs fails on simple test on __main__ (syntax error)
Use C-u C-c C-c.
See python-shell-buffer-substring function docstring:
When optional argument NOMAIN is non-nil everything under an if __name__ == '__main__' block will be removed.
And python-shell-...
5
votes
How do I get Emacs to recognize my python 3 virtual environment
I am using https://github.com/jorgenschaefer/pyvenv as well, and I set it up like so:
(use-package pyvenv
:ensure t
:config
(pyvenv-mode 1))
This pyvenv-mode 1 part is essential. This will ...
5
votes
prettify-symbols-mode character replacement regex
The closest I have gotten to replicating this is to customize the way emacs sets the font for characters for each mode I want to change
(add-to-list 'font-lock-extra-managed-props 'display)
(font-...
5
votes
Can't get realgud to work with pdb
There are a couple of possibilities. First, you could create a pdb shell script that invokes pdb. For example:
#!/bin/sh
python -m pdb $@
Or when you are asked Run pdb like this (pdb ...) enter, well,...
5
votes
Debug pytests in emacs
I think that there are only the following solutions:
Run tests outside of Emacs from your terminal emulator
Run tests from realgud
Run tests inside Emacs via eshell. But shell output may be corrupted, ...
5
votes
Accepted
Is there a package for semantic refactoring
Python:
https://github.com/python-rope/ropemacs
https://github.com/jorgenschaefer/elpy (also base on rope)
C++:
https://github.com/tuhdo/semantic-refactor
https://github.com/thoni56/c-xrefactory
5
votes
flycheck cannot enable python-flake8 configuration file not found
You can set the path to your flake8 configuration with:
(setq flycheck-flake8rc "/path/to/your/flake8-config-file")
As for enabling there are different ways of doing it I prefer to use an add-hook ...
5
votes
Accepted
does one has to explicity enable python-mode etc. to work with python files?
python-mode.el (from https://gitlab.com/python-mode-devs/python-mode) has more "bells-and-whistles" than python.el (included with Emacs). Things like better integration with IPython and auto-...
5
votes
How do I disable python-help
nega nailed it. Turning off eldoc fixed my problems. I would have never know that was what to look for.
More detail here:
How to globally disable eldoc?
5
votes
Accepted
Why is my Python indentation set to 8 locally by default?
The default is 4 spaces:
(defcustom python-indent-offset 4
"Default indentation offset for Python."
...
But python-mode guesses the spaces when opening a file and overwrites the default locally. ...
5
votes
Annoying "error in process filter: Overlapping strings detected"
There's a workaround suggested in https://github.com/jorgenschaefer/elpy/issues/1381#issuecomment-434313600
Adding (setq elpy-eldoc-show-current-function nil) to my emacs init file makes it stop ...
5
votes
How can I make python-mode correctly indent python's match statement?
I am also using 27.2. What worked for me, clued by this question
Update python.el to 28 (probably not necessary)
M-x find-library, "python"
Add "match" and case" in this ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
python × 633org-mode × 65
elpy × 65
org-babel × 55
indentation × 48
ipython × 48
spacemacs × 36
debugging × 28
flycheck × 22
shell × 21
lsp-mode × 20
company-mode × 19
syntax-highlighting × 17
comint × 17
osx × 13
tramp × 13
repl × 13
ide × 13
init-file × 12
jedi × 12
anaconda-mode × 12
key-bindings × 11
completion × 11
auto-complete-mode × 11
font-lock × 10