Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 42 lines (37 sloc) 1.32 kb
147ff3b Guru Devanla Emacs scripts
authored
1 ;; Use at your own risk!!
2 ;; add the following lines to .emacs file.
3 ;; When a function header needs to be generated, place the cursor
4 ;; on the same line as function definition and call the function
5 ;; generate-header. Alternatively, a key-binding can be added
6 ;; using (global-set-key) or adding this function to the python-mode-hook
7 ;; this method also assume the python-mode is on though
8 ;; it could be run even when not in python mode.
9 ;; TODO: Test for python-mode specifically
10
11 (defun get-function-definition(sentence)
12 (message sentence)
13 (if (string-match "def.*(.*):" sentence)
14 (match-string 0 sentence))
15 )
16
17 (defun get-parameters(sentence)
18 (setq y (get-function-definition sentence))
19 (message y)
20 (if y
21 (if (string-match "(.*)" y)
22 (match-string 0 y)))
23 )
24
25
26 (require 'thingatpt)
27 (defun generate-header()
28 (interactive)
29 (setq p (get-parameters (thing-at-point 'sentence)))
30 (forward-line 1)
31 (insert "\t\"\"\"\n\n\n")
32 (setq params (split-string p "[?\,?\(?\)?\ ]"))
33 (while params
34 (if (/= (length (chomp (car params))) 0)
35 (progn
36 (insert "\t:param ")
37 (insert (chomp (car params)))
38 (insert ": \n")))
39 (setq params (cdr params)))
40 (insert "\n\t\"\"\"\n\n")
41 )
Something went wrong with that request. Please try again.