Compare commits

...

6 Commits

Author SHA1 Message Date
Gerard Vermeulen
a371e6c9ae Fixes in egrave-faces make these work-arounds superfluous 2023-01-17 08:08:27 +01:00
Gerard Vermeulen
432d13a03c Add line number option to Python source blocks 2023-01-17 08:07:15 +01:00
Gerard Vermeulen
a4a5b115db Ensure that providecolor is defined 2023-01-17 08:02:11 +01:00
Gerard Vermeulen
d5457b9ebd Update the sections on `eglot' with Python 2023-01-13 17:49:43 +01:00
Gerard Vermeulen
189cb48440 Try to fix the warning due to setting `org-babel-load-languages' 2023-01-13 16:57:56 +01:00
Gerard Vermeulen
7a77e2d736 Remove a binding to a removed command 2023-01-13 16:56:30 +01:00

View File

@ -1463,8 +1463,6 @@ completion function [[info:elisp#Minibuffer Completion][completing-read]]. List
;; C-c bindings (current-global-map)
(global-set-key (kbd "C-c h") #'consult-history)
(global-set-key (kbd "C-c m") #'consult-mode-command)
;; C-h bindings (help-map)
(define-key help-map (kbd "a") #'consult-apropos)
;; C-x bindings (ctl-x-map)
(define-key ctl-x-map (kbd "M-:") #'consult-complex-command)
(define-key ctl-x-map (kbd "b") #'consult-buffer)
@ -2046,29 +2044,26 @@ list detailing and motivating each listing:
#+name: lst:set-org-options
#+begin_src emacs-lisp
(with-eval-after-load 'org
(custom-set-variables
`(org-babel-load-languages
(delq nil '((C . t)
(calc . t)
,(when (fboundp 'grapviz-dot-mode) '(dot . t))
(emacs-lisp . t)
(eshell . t)
,(when (fboundp 'fennel-mode) '(fennel . t))
(fortran . t)
,(when (fboundp 'gnuplot-mode) '(gnuplot . t))
(js . t)
(latex . t)
(lisp . t)
,(when (fboundp 'lua-mode) '(lua . t))
,(when (fboundp 'maxima-mode) '(maxima . t))
(org . t)
(perl . t)
;; The next two functions are not bound during bootstrap.
,(when (and (fboundp 'choose-common-python-interpreter)
(fboundp 'choose-common-python-linter))
'(python . t))
(shell . t)))))
(setopt
org-babel-load-languages
`((C . t)
(calc . t)
(dot . ,(fboundp 'grapviz-dot-mode))
(emacs-lisp . t)
(fortran . t)
(gnuplot . ,(fboundp 'gnuplot-mode))
(js . t)
(latex . t)
(lisp . t)
(lua . ,(fboundp 'lua-mode))
(maxima . ,(fboundp 'maxima-mode))
(org . t)
(perl . t)
;; The Python setup uses the two functions below.
;; Those functions are not yet bound during bootstrap.
(python . ,(and (fboundp 'choose-common-python-interpreter)
(fboundp 'choose-common-python-linter)))
(shell . t))
org-export-backends '(ascii beamer html icalendar latex odt texinfo)
org-file-apps '((auto-mode . emacs)
(directory . emacs)
@ -2091,13 +2086,13 @@ list detailing and motivating each listing:
("l" . "export latex")
("q" . "quote")
("s" . "src")
("p" . "src python -i :session")
("p" . "src python -n -i :session")
("v" . "verse"))))
#+end_src
#+caption[Set =org-babel= options]:
#+caption: Set =org-babel=.
#+name: lst:set-org-babel-options
#+caption[Setup =org-babel=]:
#+caption: Setup =org-babel=.
#+name: lst:setup-org-babel
#+begin_src emacs-lisp
(with-eval-after-load 'ob-core
(setopt org-confirm-babel-evaluate nil))
@ -2511,7 +2506,8 @@ this facility to a level acceptable for my workflow:
blocks to "floating unbreakable with caption" or "non-floating breakable
without caption" LaTeX environments. This is a partial work-around, but part
of my workflow.
2. Listing [[lst:ensure-engrave-faces-with-latex-face-apply-fix]] makes
2. Fixed in [[https://elpa.gnu.org/devel/engrave-faces.html][engrave-faces-0.3.1.0.20230115.70118]]: listing
[[lst:ensure-engrave-faces-with-latex-face-apply-fix]] makes
=engrave-faces-latex-face-apply= handle symbolic color name strings (in
addition to the hexadecimal strings). Since faces in for instance
src_emacs-lisp{(find-library "org-faces")} and src_emacs-lisp{(find-library
@ -2523,7 +2519,8 @@ this facility to a level acceptable for my workflow:
obtain the same result. Currently, I prefer to tangle listing
[[lst:ensure-engrave-faces-with-attribute-values-fix]] to the =user-init-file=
instead of listing [[lst:ensure-engrave-faces-with-latex-face-apply-fix]].
3. Listing [[lst:ensure-engrave-faces-with-latex-face-mapper-fix]] makes
3. Fixed in [[https://elpa.gnu.org/devel/engrave-faces.html][engrave-faces-0.3.1.0.20230115.70118]]: listing
[[lst:ensure-engrave-faces-with-latex-face-mapper-fix]] makes
=engrave-faces-latex-face-mapper= handle horizontal and vertical spacing in
multiple line documentation strings correctly. For instance, without this fix
the mishandling of vertical and horizontal spacing destroys the indentation
@ -2590,6 +2587,7 @@ environments and non-floating breakable LaTeX environments by means of
\\renewcommand\\theFancyVerbLine{
\\normalsize\\color{black!40!white}\\arabic{FancyVerbLine}}
% In case engrave-faces-latex-gen-preamble has not been run.
\\usepackage{xcolor}
\\providecolor{EfD}{HTML}{f7f7f7}
\\providecolor{EFD}{HTML}{28292e}
% To use \\DeclareTColorBox from the tcolorbox package:
@ -2657,7 +2655,7 @@ environments and non-floating breakable LaTeX environments by means of
#+caption[Fix engraving of symbolic color names in =engrave-faces=]:
#+caption: Fix engraving of symbolic colors names in =engrave-faces=.
#+name: lst:ensure-engrave-faces-with-attribute-values-fix
#+begin_src emacs-lisp
#+begin_src emacs-lisp :tangle no
(when (require 'engrave-faces nil t)
(defun engrave-faces-attribute-values-around (efav-fun &rest args)
(let ((values (apply efav-fun args))
@ -2680,7 +2678,7 @@ environments and non-floating breakable LaTeX environments by means of
#+caption: Fix engraving of horizontal and vertical spacing in multiple line
#+caption: documentation strings.
#+name: lst:ensure-engrave-faces-with-latex-face-mapper-fix
#+begin_src emacs-lisp
#+begin_src emacs-lisp :tangle no
(when (require 'engrave-faces-latex nil t)
(defun engrave-faces-latex-face-mapper-override (faces content)
"Create a LaTeX representation of CONTENT with FACES applied."
@ -3871,14 +3869,15 @@ Listing [[lst:configure-writegood-mode]] configures [[https://github.com/bnbeckw
:CUSTOM_ID: sec:programming-tools
:END:
** [[info:eglot#Top][Eglot (info)]] or [[https://github.com/joaotavora/eglot][Eglot]]
** [[info:eglot#Top][Eglot (info)]]
:PROPERTIES:
:CUSTOM_ID: sec:eglot
:END:
[[https://github.com/joaotavora/eglot#readme][Emacs polyGLOT (Eglot)]] is an Emacs language-server-protocol client that stays
out of the way. The following listings contribute to a programming language
mode independent [[https://github.com/joaotavora/eglot][Eglot]] configuration:
out of your way. [[info:eglot#Top][Eglot (info)]] is a builtin since Emacs-29.0.60. The following
listings contribute to a programming language mode independent [[https://github.com/joaotavora/eglot][Eglot]]
configuration:
1. Listing [[lst:minimal-eglot-setup][minimal Eglot setup]] ensures installation of [[https://github.com/joaotavora/eglot][Eglot]], shows how to get
debug information from the [[https://github.com/python-lsp/python-lsp-server][Python LSP server]], and adds key bindings to
=eglot-mode-keymap=.
@ -4272,7 +4271,8 @@ install and use [[https://gitlab.com/andreyorst/ob-fennel][ob-fennel]] with the
(ensure-package-installation 'fennel-mode 'quelpa))
(unless (package-installed-p 'ob-fennel)
(quelpa '(ob-fennel :repo "andreyorst/ob-fennel" :fetcher gitlab)))
(ensure-package-selection 'ob-fennel))
(when (ensure-package-selection 'ob-fennel)
(org-babel-do-load-languages 'fennel (fboundp 'fennel-mode))))
#+end_src
#+caption[Fennel example]:
@ -4350,9 +4350,11 @@ print(1+1);
:PROPERTIES:
:CUSTOM_ID: sec:python-programming
:END:
The [[https://www.emacswiki.org/emacs/PythonProgrammingInEmacs][Python Programming in Emacs]] wiki page lists options to enhance Emacs's
built-in ~python-mode~. Here, the focus is on three packages:
1. [[https://github.com/joaotavora/eglot][Eglot - Emacs polyGLOT: an Emacs LSP client that stays out of your way]]. The
built-in ~python-mode~. Here, the focus is on two Emacs packages and four Python
packages:
1. [[#sec:eglot][Eglot - Emacs polyGLOT: a builtin LSP client since Emacs-29.0.60]]. The
maintainer also contributes to Emacs itself and has a deep understanding of
[[https://sheer.tj/the_way_of_emacs.html][the Way of Emacs]]. He refuses to add new features without seeing how they fit
into [[https://sheer.tj/the_way_of_emacs.html][the Way of Emacs]] as this discussion on [[https://github.com/joaotavora/eglot/issues/523][org-mode source code blocks]]
@ -4360,7 +4362,13 @@ built-in ~python-mode~. Here, the focus is on three packages:
2. [[https://jedi.readthedocs.io/en/latest/][Jedi]] is a static analysis tool for Python that is typically used in plugins
for editors or integrated development environments. Jedi has a focus on
autocompletion and object definition lookup functionality.
3. [[https://github.com/astoff/code-cells.el#readme][Code-cells]] allows to edit [[https://ipython.org/notebook.html][IPython or Jupyter notebooks]] in Emacs with help
3. [[https://github.com/charliermarsh/ruff#readme][Ruff]] is an extremely fast Python linter and a replacement for [[https://flake8.pycqa.org/en/latest/][Flake8]] with a
variety of its plugins. [[https://notes.crmarsh.com/][Charlie Marsh]] explains why he started [[https://pypi.org/project/ruff/][Ruff]] in the
post [[https://notes.crmarsh.com/python-tooling-could-be-much-much-faster][Python tooling could be much faster]].
4. [[https://github.com/python-lsp/python-lsp-server#readme][Python LSP Server]] is in my opinion the most complete [[https://en.wikipedia.org/wiki/Language_Server_Protocol][Language Server Protocol]]
implementation for Python and it handles [[https://github.com/charliermarsh/ruff#readme][Ruff]] thanks to the [[https://github.com/python-lsp/python-lsp-ruff][python-lsp-ruff]]
plugin.
5. [[https://github.com/astoff/code-cells.el#readme][Code-cells]] allows to edit [[https://ipython.org/notebook.html][IPython or Jupyter notebooks]] in Emacs with help
from either [[https://github.com/mwouts/jupytext][Jupytext]] or [[https://pandoc.org/][Pandoc]].
Here are links covering how to integrate Emacs, Python and a Python LSP
@ -4396,8 +4404,6 @@ of src_emacs-lisp{(choose-common-python-linter)} from:
1. [[https://github.com/PyCQA/pyflakes][Pyflakes - simple tool which checks Python source files for errors]].
2. [[https://flake8.pycqa.org/en/latest/][Flake8 - your tool for style guide enforcement]].
3. [[https://github.com/charliermarsh/ruff][Ruff - an extremely fast Python linter written in Rust]].
I use [[https://pypi.org/project/ruff/][Ruff]] to replace [[https://pypi.org/project/flake8/][Flake8]] with a variety of its plugins. [[https://notes.crmarsh.com/][Charlie Marsh]]
explains why he started [[https://pypi.org/project/ruff/][Ruff]] in the post [[https://notes.crmarsh.com/python-tooling-could-be-much-much-faster][Python tooling could be much faster]].
Listing [[lst:pyproject-toml-kickoff][kickoff pyproject.toml proposal]] facilitates dropping a [[https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml][pyproject.toml]]
file into Python projects which anyhow should switch to using a [[https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml][pyproject.toml]]