~a-roehler/python-mode/XEmacs-compat-test

« back to all changes in this revision

Viewing changes to devel/fundocu2infoformats.el

  • Committer: Andreas Roehler
  • Date: 2012-01-25 20:31:09 UTC
  • Revision ID: andreas.roehler@online.de-20120125203109-cfag2pbgyrxyh3xa
renamed: tools/ => devel/

make visible these files are not for common usage











Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(defun python-components-mode-list-actives (&optional directory)
 
2
  "Return a list, which components will be loaded. "
 
3
  (interactive)
 
4
  (let ((directory (or directory default-directory))
 
5
        componentslist)
 
6
    (find-file (concat directory "python-components-mode.el"))
 
7
    (save-restriction
 
8
      (widen)
 
9
      (goto-char (point-min))
 
10
      (while (re-search-forward "^[ \t]*(require '\\([^)]+\\))" nil (quote move) 1)
 
11
        (when (save-match-data
 
12
                (string-match "python-components" (match-string-no-properties 0)))
 
13
          (add-to-list 'componentslist (prin1-to-string (match-string-no-properties 1)))))
 
14
      (dolist (ele componentslist)
 
15
        (find-file (concat directory ele)
 
16
                   (finds (concat ele ".el")))))))
 
17
 
 
18
(defun finds-from-programm ()
 
19
  (let ((directory-in default-directory)
 
20
        (directory-out (concat default-directory "doc"))
 
21
        (erg (concat default-directory "python-mode.el"))
 
22
        (buffer (current-buffer)))
 
23
    (message "Lade %s" erg)
 
24
    (find-file erg)
 
25
    (finds buffer directory-in directory-out)))
 
26
 
 
27
(defun finds (&optional buffer directory-in directory-out)
 
28
  "List all commands in file alongside with their documentation. "
 
29
  (interactive)
 
30
  (let* ((oldbuf (buffer-name (or buffer (current-buffer))))
 
31
         (file (buffer-file-name))
 
32
         (orgname (concat (substring oldbuf 0 (string-match "\\." oldbuf)) ".org"))
 
33
         (reSTname (concat (substring oldbuf 0 (string-match "\\." oldbuf)) ".rst"))
 
34
         (directory-in (or directory-in default-directory))
 
35
         (directory-out-prepare
 
36
          (if directory-out
 
37
              (if
 
38
                  (string-match ".+/$" directory-out)
 
39
                  directory-out
 
40
                (concat directory-out "/"))
 
41
            default-directory))
 
42
         (directory-out (unless (and directory-out (string-match ".*/doc" directory-out))  (concat directory-out-prepare "doc/"))))
 
43
    (finds-base oldbuf file orgname reSTname directory-in directory-out)))
 
44
 
 
45
(defun finds-base (oldbuf file orgname reSTname directory-in directory-out)
 
46
  (save-restriction
 
47
    (let (commandslist)
 
48
      (widen)
 
49
      (goto-char (point-min))
 
50
      (eval-buffer)
 
51
      (while (re-search-forward "^[ \t]*(defun +\\(\\w+\\|\\s_+\\)+" nil t)
 
52
        (goto-char (match-beginning 1))
 
53
        (when (commandp (symbol-at-point))
 
54
          (lexical-let* ((name (symbol-at-point))
 
55
                         (docu (documentation name)))
 
56
            (unless docu (message "don't see docu string for %s" (prin1-to-string name)))
 
57
            (add-to-list 'commandslist (cons (prin1-to-string name) docu))
 
58
            ;; (message "%s" (car commandslist))
 
59
            (end-of-defun))))
 
60
      (setq commandslist (nreverse commandslist))
 
61
      (with-temp-buffer
 
62
        (switch-to-buffer (current-buffer))
 
63
        (insert (concat ";; a list of " oldbuf " commands
 
64
\(setq " oldbuf "-commands (quote "))
 
65
        (insert (prin1-to-string commandslist))
 
66
        (insert "))")
 
67
        (eval-buffer)
 
68
        (write-file (concat directory-out "commands-" (concat (substring oldbuf 0 (string-match "\\." oldbuf)) ".el"))))
 
69
      (with-temp-buffer
 
70
        ;; org
 
71
        (insert (concat (capitalize (substring oldbuf 0 (string-match "\." oldbuf))) " commands" "\n\n"))
 
72
        (dolist (ele commandslist)
 
73
          (insert (concat "* "(car ele) "\n"))
 
74
          (insert (concat "   " (cdr ele) "\n")))
 
75
        (write-file (concat directory-out "commands-" orgname))
 
76
        (find-file (concat directory-out "commands-" orgname)))
 
77
      (with-temp-buffer
 
78
        ;; reST
 
79
        (insert (concat (capitalize (substring oldbuf 0 (string-match "\." oldbuf))) " commands" "\n"))
 
80
        (insert (concat (make-string (length (concat (substring oldbuf 0 (string-match "\." oldbuf)) " commands")) ?\=) "\n\n"))
 
81
        (dolist (ele commandslist)
 
82
          (insert (concat (car ele) "\n"))
 
83
          (insert (concat (make-string (length (car ele)) ?\-) "\n"))
 
84
          (insert (concat (cdr ele) "\n\n")))
 
85
        (write-file (concat directory-out "commands-" reSTname))
 
86
        (find-file (concat directory-out "commands-" reSTname))))))
 
87
;; (dolist (ele commandslist)))