summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimeon Simeonov2023-09-25 09:17:11 +0200
committerSimeon Simeonov2023-09-25 09:17:11 +0200
commit83718bb1038c175d84204ed57d5aebe380811c61 (patch)
tree4b20655fb0fdeb7597e6d371e506c0d798fa1410
parent0293defdea75407b6e11b3ebef3bc0d49fac9a58 (diff)
Update yasnippet .yas-setup.el
-rw-r--r--.emacs.d/snippets/prog-mode/.yas-setup.el3
-rw-r--r--.emacs.d/snippets/python-mode.statnett/.yas-setup.el19
-rw-r--r--.emacs.d/snippets/python-mode/.yas-setup.el19
3 files changed, 32 insertions, 9 deletions
diff --git a/.emacs.d/snippets/prog-mode/.yas-setup.el b/.emacs.d/snippets/prog-mode/.yas-setup.el
index 22a8168..486ae47 100644
--- a/.emacs.d/snippets/prog-mode/.yas-setup.el
+++ b/.emacs.d/snippets/prog-mode/.yas-setup.el
@@ -1,8 +1,5 @@
1(require 'yasnippet) 1(require 'yasnippet)
2 2
3(defun yas-with-comment (str)
4 (format "%s%s%s" comment-start str comment-end))
5
6;; whitespace removing functions from Magnar Sveen ;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3;; whitespace removing functions from Magnar Sveen ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7(defun yas-s-trim-left (s) 4(defun yas-s-trim-left (s)
8 "Remove whitespace at the beginning of S." 5 "Remove whitespace at the beginning of S."
diff --git a/.emacs.d/snippets/python-mode.statnett/.yas-setup.el b/.emacs.d/snippets/python-mode.statnett/.yas-setup.el
index 7603e4d..76af532 100644
--- a/.emacs.d/snippets/python-mode.statnett/.yas-setup.el
+++ b/.emacs.d/snippets/python-mode.statnett/.yas-setup.el
@@ -14,12 +14,25 @@
14 (max-len (if args (apply 'max (mapcar (lambda (x) (length (nth 0 x))) args)) 0)) 14 (max-len (if args (apply 'max (mapcar (lambda (x) (length (nth 0 x))) args)) 0))
15 (formatted-args (mapconcat 15 (formatted-args (mapconcat
16 (lambda (x) 16 (lambda (x)
17 (concat ":param " (nth 0 x) ":\n:type " (nth 0 x) ":\n" 17 (concat (nth 0 x) (make-string (- max-len (length (nth 0 x))) ? ) " -- "
18 (if (nth 1 x) (concat "\(default " (nth 1 x) "\)")))) 18 (if (nth 1 x) (concat "\(default " (nth 1 x) "\)"))))
19 args 19 args
20 indent))) 20 indent)))
21 (unless (string= formatted-args "") 21 (unless (string= formatted-args "")
22 (mapconcat 'identity (list "Keyword Arguments:" formatted-args) indent)))) 22 (mapconcat 'identity (list "Keyword Arguments:" formatted-args) indent))))
23 23
24(add-hook 'python-mode-hook 24(defun python-args-to-docstring-numpy ()
25 '(lambda () (set (make-local-variable 'yas-indent-line) 'fixed))) 25 "return docstring format for the python arguments in yas-text"
26 (let* ((args (python-split-args yas-text))
27 (format-arg (lambda(arg)
28 (concat (nth 0 arg) " : " (if (nth 1 arg) ", optional") "\n")))
29 (formatted-params (mapconcat format-arg args "\n"))
30 (formatted-ret (mapconcat format-arg (list (list "out")) "\n")))
31 (unless (string= formatted-params "")
32 (mapconcat 'identity
33 (list "\nParameters\n----------" formatted-params
34 "\nReturns\n-------" formatted-ret)
35 "\n"))))
36
37
38(add-hook 'python-mode-hook #'yasnippet-snippets--fixed-indent)
diff --git a/.emacs.d/snippets/python-mode/.yas-setup.el b/.emacs.d/snippets/python-mode/.yas-setup.el
index 7603e4d..76af532 100644
--- a/.emacs.d/snippets/python-mode/.yas-setup.el
+++ b/.emacs.d/snippets/python-mode/.yas-setup.el
@@ -14,12 +14,25 @@
14 (max-len (if args (apply 'max (mapcar (lambda (x) (length (nth 0 x))) args)) 0)) 14 (max-len (if args (apply 'max (mapcar (lambda (x) (length (nth 0 x))) args)) 0))
15 (formatted-args (mapconcat 15 (formatted-args (mapconcat
16 (lambda (x) 16 (lambda (x)
17 (concat ":param " (nth 0 x) ":\n:type " (nth 0 x) ":\n" 17 (concat (nth 0 x) (make-string (- max-len (length (nth 0 x))) ? ) " -- "
18 (if (nth 1 x) (concat "\(default " (nth 1 x) "\)")))) 18 (if (nth 1 x) (concat "\(default " (nth 1 x) "\)"))))
19 args 19 args
20 indent))) 20 indent)))
21 (unless (string= formatted-args "") 21 (unless (string= formatted-args "")
22 (mapconcat 'identity (list "Keyword Arguments:" formatted-args) indent)))) 22 (mapconcat 'identity (list "Keyword Arguments:" formatted-args) indent))))
23 23
24(add-hook 'python-mode-hook 24(defun python-args-to-docstring-numpy ()
25 '(lambda () (set (make-local-variable 'yas-indent-line) 'fixed))) 25 "return docstring format for the python arguments in yas-text"
26 (let* ((args (python-split-args yas-text))
27 (format-arg (lambda(arg)
28 (concat (nth 0 arg) " : " (if (nth 1 arg) ", optional") "\n")))
29 (formatted-params (mapconcat format-arg args "\n"))
30 (formatted-ret (mapconcat format-arg (list (list "out")) "\n")))
31 (unless (string= formatted-params "")
32 (mapconcat 'identity
33 (list "\nParameters\n----------" formatted-params
34 "\nReturns\n-------" formatted-ret)
35 "\n"))))
36
37
38(add-hook 'python-mode-hook #'yasnippet-snippets--fixed-indent)