Remove the python-add-docstring function

This commit is contained in:
Gergely Polonkai 2023-10-22 06:44:15 +02:00
parent 8290095a01
commit 87e0fb1b74
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4

View File

@ -742,22 +742,6 @@ To temporarily hide the mode line.
** Programming related
*** Check if we are inside a string
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/prog-in-string-p ()
"Return t if point is inside a string."
(nth 3 (syntax-ppss)))
#+END_SRC
*** Check if we are inside a comment
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/prog-in-comment-p ()
"Return t if point is inside a comment."
(nth 4 (syntax-ppss)))
#+END_SRC
*** Add code references to Org documents
:PROPERTIES:
:SOURCE: http://www.howardism.org/Technical/Emacs/capturing-content.html
@ -799,46 +783,6 @@ and a backlink to the function and the file."
(ha/org-capture-fileref-snippet f "SRC" org-src-mode func-name))))
#+END_SRC
** ~python-mode~ related
*** Add a docstring to the current thing
…be it a function, class, or a module
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/python-add-docstring ()
"Add a Python docstring to the current thing.
If point is inside a function, add docstring to that. If point
is in a class, add docstring to that. If neither, add docstring
to the beginning of the file."
(interactive)
(save-restriction
(widen)
(beginning-of-defun)
(if (not (looking-at-p "\\(def\\|class\\) "))
(progn
(goto-char (point-min))
(back-to-indentation)
(forward-char)
(while (gpolonkai/prog-in-comment-p)
(forward-line)
(back-to-indentation)
(forward-char)))
(search-forward ":")
(while (or (gpolonkai/prog-in-string-p)
(gpolonkai/prog-in-comment-p))
(search-forward ":")))
(if (eq 1 (count-lines 1 (point)))
(open-line-above)
(open-line-below))
(insert "\"\"\"")
(let ((point-pos (point)))
(open-line-below)
(insert "\"\"\"\n")
(goto-char point-pos))))
#+END_SRC
** Jinja related
*** Mark a string as translatable