1
;;; -*- lexical-binding: t; -*-
3
(defcustom py-devel-directory-out ""
4
"Output directory when developing Python-mode. "
8
(defcustom py-devel-directory-in ""
9
"Input directory when developing Python-mode. "
13
(defun python-components-mode-list-actives (&optional directory)
14
"Return a list, which components will be loaded. "
16
(let ((directory (or directory default-directory))
18
(find-file (concat directory "python-components-mode.el"))
21
(goto-char (point-min))
22
(while (re-search-forward "^[ \t]*(require '\\([^)]+\\))" nil (quote move) 1)
23
(when (save-match-data
24
(string-match "python-components" (match-string-no-properties 0)))
25
(add-to-list 'componentslist (prin1-to-string (match-string-no-properties 1)))))
26
(dolist (ele componentslist)
27
(find-file (concat directory ele)
28
(finds (concat ele ".el")))))))
30
(defun finds-from-programm ()
31
(let ((directory-in (or (and (not (string= "" py-devel-directory-in)) py-devel-directory-in) default-directory))
32
(directory-out (or (and (not (string= "" py-devel-directory-out)) py-devel-directory-out default-directory)) (concat default-directory "doc"))
33
(erg (buffer-file-name))
34
(buffer (current-buffer)))
35
(message "Lade %s" erg)
37
(finds buffer directory-in directory-out)))
39
(defvar python-mode-el-doku-list (list "autopair/autopair.el" "python-mode.el" "completion/auto-complete-pycomplete.el" "completion/company-pycomplete.el" "completion/pycomplete.el" "pymacs.el" "extensions/py-smart-operator.el"))
42
"Write doku for files listet in python-mode-el-doku-list. "
44
(dolist (ele python-mode-el-doku-list)
46
(and (load (concat "~/arbeit/emacs/python-modes/python-mode/" ele))
47
(find-file (concat "~/arbeit/emacs/python-modes/python-mode/" ele)))
50
(defun variable-docu (&optional buffer directory-in directory-out)
51
"Writes all variable in BUFFER alongside with their documentation into directory \"doc\" as \*.org and \*rst file ."
53
(variables-prepare "docu"))
55
(defun variables-base-docu (oldbuf orgname reSTname directory-in directory-out)
57
(let ((suffix (file-name-nondirectory (buffer-file-name)))
60
(goto-char (point-min))
62
(while (and (not (eobp))(re-search-forward "^(defvar [[:alpha:]]\\|^(defcustom [[:alpha:]]\\|^(defconst [[:alpha:]]" nil t 1))
63
(let* ((name (symbol-at-point))
64
(docu (documentation-property name 'variable-documentation)))
65
;; (documentation-property alias 'variable-documentation))))
66
;; (docu (get 'variable-documentation name)))
68
(add-to-list 'variableslist (cons (prin1-to-string name) docu))
69
(message "don't see docu string for %s" (prin1-to-string name))))
70
;; (add-to-list 'variableslist (list (match-string-no-properties 0)))
73
(setq variableslist (nreverse variableslist))
75
;; (switch-to-buffer (current-buffer))
76
;; (insert (concat ";; a list of " suffix " variables
77
;; \(setq " (replace-regexp-in-string "\\." "-" suffix) "-variables (quote "))
78
;; (insert (prin1-to-string variableslist))
83
;; (insert (concat (capitalize (substring oldbuf 0 (string-match "\." oldbuf))) " variables" "\n\n"))
84
;; (insert (concat suffix " variables\n\n"))
85
(insert "Python-mode variables\n\n")
86
(switch-to-buffer (current-buffer))
87
(dolist (ele variableslist)
88
(if (string-match "^;;; " (car ele))
89
(unless (or (string-match "^;;; Constants\\|^;;; Commentary\\|^;;; Code\\|^;;; Macro definitions\\|^;;; Customization" (car ele)))
91
(insert (concat (replace-regexp-in-string "^;;; " "* " (car ele)) "\n")))
92
(insert (concat "\n** "(car ele) "\n"))
93
(insert (concat " " (cdr ele) "\n\n")))
96
(write-file (concat directory-out "variables-" orgname))
97
(find-file (concat directory-out "variables-" orgname))))
101
(insert "Python-mode variables\n\n")
102
;; (insert (concat (make-string (length (concat (substring oldbuf 0 (string-match "\." oldbuf)) " variables")) ?\=) "\n\n"))
103
(insert "====================\n\n")
104
(dolist (ele variableslist)
105
(insert (concat "\n" (car ele) "\n"))
106
(insert (concat (make-string (length (car ele)) ?\-) "\n"))
107
(insert (concat (cdr ele) "\n\n")))
110
(write-file (concat directory-out "variables-" reSTname))
111
(find-file (concat directory-out "variables-" reSTname))))))
113
(defun finds (&optional buffer directory-in directory-out)
114
"Writes all commands in BUFFER alongside with their documentation into directory \"doc\" as \*.org and \*rst file ."
116
(let* ((oldbuf (buffer-name (or buffer (current-buffer))))
117
;; (file (buffer-file-name))
118
(orgname (concat (substring oldbuf 0 (string-match "\\." oldbuf)) ".org"))
119
(reSTname (concat (substring oldbuf 0 (string-match "\\." oldbuf)) ".rst"))
120
(directory-in (or directory-in (and (not (string= "" py-devel-directory-in)) py-devel-directory-in) default-directory))
121
(directory-out (or directory-out (expand-file-name finds-directory-out))))
122
(finds-base oldbuf orgname reSTname directory-in directory-out)))
124
(defun finds-base (oldbuf orgname reSTname directory-in directory-out)
126
(let ((suffix (file-name-nondirectory (buffer-file-name)))
129
(goto-char (point-min))
131
(while (and (not (eobp))(re-search-forward "^(defun [[:alpha:]]\\|^;;; .+" nil t 1)) ;
132
(when (save-match-data (commandp (symbol-at-point)))
133
(let* ((name (symbol-at-point))
134
(docu (documentation name)))
136
(add-to-list 'commandslist (cons (prin1-to-string name) docu))
137
(message "don't see docu string for %s" (prin1-to-string name)))))
138
;; (add-to-list 'commandslist (list (match-string-no-properties 0)))
141
(setq commandslist (nreverse commandslist))
143
(switch-to-buffer (current-buffer))
144
(insert (concat ";; a list of " suffix " commands
145
\(setq " (replace-regexp-in-string "\\." "-" suffix) "-commands (quote "))
146
(insert (prin1-to-string commandslist))
151
;; (insert (concat (capitalize (substring oldbuf 0 (string-match "\." oldbuf))) " commands" "\n\n"))
152
(insert (concat suffix " commands\n\n"))
153
(dolist (ele commandslist)
154
(if (string-match "^;;; " (car ele))
155
(unless (or (string-match "^;;; Constants\\|^;;; Commentary\\|^;;; Code\\|^;;; Macro definitions\\|^;;; Customization" (car ele)))
157
(insert (concat (replace-regexp-in-string "^;;; " "* " (car ele)) "\n")))
158
(insert (concat "** "(car ele) "\n"))
159
(insert (concat " " (cdr ele) "\n\n"))))
160
(write-file (concat directory-out "commands-" orgname))
161
(find-file (concat directory-out "commands-" orgname)))
164
(insert "Commands\n\n")
165
;; (insert (concat (make-string (length (concat (substring oldbuf 0 (string-match "\." oldbuf)) " commands")) ?\=) "\n\n"))
166
(insert "====================\n\n")
167
(dolist (ele commandslist)
168
(insert (concat (car ele) "\n"))
169
(insert (concat (make-string (length (car ele)) ?\-) "\n"))
170
(insert (concat (cdr ele) "\n\n")))
171
(write-file (concat directory-out "commands-" reSTname))
172
(find-file (concat directory-out "commands-" reSTname))))))
174
(defun write-defcustom-docus (&optional buffer directory-in directory-out)
175
"Writes all customizable variables w/ documentation into directory \"doc\" as \*.org and \*rst file ."
177
(let* ((oldbuf (buffer-name (or buffer (current-buffer))))
178
;; (file (buffer-file-name))
179
(orgname (concat (substring oldbuf 0 (string-match "\\." oldbuf)) ".org"))
180
(reSTname (concat (substring oldbuf 0 (string-match "\\." oldbuf)) ".rst"))
181
(directory-in (or directory-in (and (not (string= "" py-devel-directory-in)) py-devel-directory-in) default-directory))
182
(directory-out (or directory-out (expand-file-name finds-directory-out))))
183
(defcustom-docu-base oldbuf orgname reSTname directory-in directory-out)))
185
(defun defcustom-docu-base (oldbuf orgname reSTname directory-in directory-out)
187
(let ((suffix (file-name-nondirectory (buffer-file-name)))
189
(goto-char (point-min))
190
(while (and (not (eobp))(re-search-forward "^(defcustom [[:alpha:]]" nil t 1))
191
(if (save-match-data (boundp (symbol-at-point)))
192
(let* ((name (variable-at-point))
194
(or (documentation-property
195
name 'variable-documentation)
196
(documentation-property
197
alias 'variable-documentation))))
198
(unless docu (message "don't see docu string for %s" (prin1-to-string name)))
199
(add-to-list 'varslist (cons (prin1-to-string name) docu))
201
(add-to-list 'varslist (list (match-string-no-properties 0)))))
202
(setq varslist (nreverse varslist))
204
;; (switch-to-buffer (current-buffer))
205
(insert (concat suffix " variables\n\n"))
206
(dolist (ele varslist)
207
(insert (concat "** "(car ele) "\n"))
208
(insert (concat " " (cdr ele) "\n\n"))
212
;; (delete-region (point) (goto-char (point-max)))
213
(delete-region (point)(point-max))
216
(goto-char (point-min))
217
(indent-region (point-min) (point-max) )
218
(write-file (concat directory-out "variables-" orgname))
219
(find-file (concat directory-out "variables-" orgname)))
222
(insert "Variables\n\n")
223
;; (insert (concat (make-string (length (concat (substring oldbuf 0 (string-match "\." oldbuf)) " commands")) ?\=) "\n\n"))
224
(insert "====================\n\n")
225
(dolist (ele varslist)
226
(insert (concat (car ele) "\n"))
227
(insert (concat (make-string (length (car ele)) ?\-) "\n"))
228
(insert (concat (cdr ele) "\n\n")))
229
(write-file (concat directory-out "variables-" reSTname))
230
(find-file (concat directory-out "variables-" reSTname))
233
(defun py-variables-unused (&optional buffer directory-in directory-out)
234
"Report unused variables. "
236
(variables-prepare "unused"))
238
(defun variables-prepare (kind)
239
"Used by variable-finds, variable-states. "
240
(let* ((oldbuf (buffer-name (or buffer (current-buffer))))
241
;; (file (buffer-file-name))
242
(orgname (concat (substring oldbuf 0 (string-match "\\." oldbuf)) ".org"))
243
(reSTname (concat (substring oldbuf 0 (string-match "\\." oldbuf)) ".rst"))
244
(directory-in default-directory)
245
(directory-out (or directory-out (expand-file-name finds-directory-out)))
246
(command (concat "variables-base-" kind)))
247
(funcall (intern-soft command) oldbuf orgname reSTname directory-in directory-out)))
249
(defun variables-base-unused (oldbuf orgname reSTname directory-in directory-out)
251
(let ((suffix (file-name-nondirectory (buffer-file-name)))
254
(goto-char (point-min))
256
(while (and (not (eobp))(re-search-forward "^(defvar [[:alpha:]]\\|^(defcustom [[:alpha:]]\\|^(defconst [[:alpha:]]" nil t 1))
257
(let* ((name (symbol-at-point)))
259
(or (eq name 'py-menu)
260
(eq name 'python-mode-map)
261
(string-match "syntax-table" (prin1-to-string name))
263
(re-search-forward (concat "\\_<" (prin1-to-string name) "\\_>") nil t 1)))
264
(add-to-list 'variableslist (prin1-to-string name))))
266
(setq variableslist (nreverse variableslist))
268
(set-buffer (get-buffer-create "Unused-Python-mode-variables.txt"))
271
(insert "Unused python-mode variables\n\n")
272
(switch-to-buffer (current-buffer))
273
(dolist (ele variableslist)
274
(insert (concat ele "\n"))
279
(defun functions-list-base (oldbuf orgname reSTname directory-in directory-out)
281
(let ((suffix (file-name-nondirectory (buffer-file-name)))
284
(goto-char (point-min))
286
(while (and (not (eobp))(re-search-forward "^(defun [[:alpha:]]+" nil t 1)) ;
287
(unless (save-match-data (commandp (symbol-at-point)))
288
(let* ((name (symbol-at-point)))
289
(add-to-list 'functionslist name)))
291
(set-buffer (get-buffer-create "Unused-Python-mode-functions.txt"))
294
(insert "Unused python-mode functions\n\n")
295
(switch-to-buffer (current-buffer))
296
(dolist (ele functionslist)
297
(insert (concat (prin1-to-string ele) "\n"))
301
(defun py-functions-unused (&optional buffer directory-in directory-out)
302
"Report unused functions. "
304
(functions-prepare "unused"))
306
(defun functions-prepare (kind)
307
"Used by variable-finds, variable-states. "
308
(let* ((oldbuf (buffer-name (or buffer (current-buffer))))
309
;; (file (buffer-file-name))
310
(orgname (concat (substring oldbuf 0 (string-match "\\." oldbuf)) ".org"))
311
(reSTname (concat (substring oldbuf 0 (string-match "\\." oldbuf)) ".rst"))
312
(directory-in default-directory)
313
(directory-out (or directory-out (expand-file-name finds-directory-out)))
314
(command (concat "functions-base-" kind)))
315
(funcall (intern-soft command) oldbuf orgname reSTname directory-in directory-out)))
317
(defun functions-base-unused (oldbuf orgname reSTname directory-in directory-out)
319
(let ((suffix (file-name-nondirectory (buffer-file-name)))
322
(goto-char (point-min))
324
(while (and (not (eobp))(re-search-forward "^(defun [[:alpha:]]+" nil t 1)) ;
325
(unless (or (save-match-data (commandp (setq name (symbol-at-point))))
327
(goto-char (point-min))
328
(re-search-forward (concat "\\_<\(" (prin1-to-string name) "\\_>") nil t 1)))
329
(add-to-list 'functionslist name))
331
(set-buffer (get-buffer-create "Unused-Python-mode-functions.txt"))
334
(insert "Unused python-mode functions\n\n")
335
(switch-to-buffer (current-buffer))
336
(dolist (ele functionslist)
337
(insert (concat (prin1-to-string ele) "\n"))
341
(defun py-all-docu ()
342
"Write documentations commands and user-defined variables "
344
(find-file "~/arbeit/emacs/python-modes/python-mode/python-mode.el")
349
(write-defcustom-docus))