code_junkie

Generating a code from Emacs

Nov 13th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. newcommand{cA}{mathcal A}
  2. newcommand{cB}{mathcal B}
  3. newcommand{cC}{mathcal C}
  4. ...
  5. ...
  6. newcommand{cY}{mathcal Y}
  7. newcommand{cZ}{mathcal Z}
  8.  
  9. A
  10. B
  11. C
  12. D
  13. .
  14. .
  15. .
  16. Y
  17. Z
  18.  
  19. (loop
  20. for n from (string-to-char "A") to (string-to-char "Z")
  21. for c = (char-to-string n)
  22. do (insert (concat "\newcommand{\c" c "}{\mathcal " c "}n")))
  23.  
  24. (loop
  25. for n from (string-to-char "A") to (string-to-char "Z")
  26. for c = (char-to-string n)
  27. do (insert (concat "\newcommand{\c" c "}{\mathcal " c "}n")))
  28.  
  29. (loop
  30. for n from (string-to-char "A") to (string-to-char "Z")
  31. for c = (char-to-string n)
  32. do (insert (concat "\newcommand{\c" c "}{\mathcal " c "}n")))
  33.  
  34. perl -e"print map {q(newcommand{c).$_.q(}{mathcal ).qq($_}n)} A..Z
  35.  
  36. (loop
  37. for n from (string-to-char "A") to (string-to-char "Z")
  38. for c = (char-to-string n)
  39. do (insert (concat "\newcommand{\c" c "}{\mathcal " c "}n")))
  40.  
  41. (loop for n from ?A to ?Z
  42. do (insert (format "\newcommand{\c%s}{\mathcal %s}n" n n)))
  43.  
  44. (defun my-append (str)
  45. "Substitute A-Z in STR and insert into current buffer.
  46.  
  47. Looks for '--HERE--' (without quotes) in string STR, substitutes the
  48. letters A-Z in the string and then inserts the resulting string into
  49. the current buffer."
  50. (interactive "sInput String: ")
  51. (let ((lcv 0)
  52. letter newstr)
  53. (while (< lcv 26)
  54. (setq letter (+ ?A lcv))
  55.  
  56. (insert (replace-regexp-in-string "--HERE--" (char-to-string letter) str t t) "n")
  57.  
  58. (setq lcv (+ lcv 1)))))
  59.  
  60. (defun somefun(inputval)
  61. (interactive "sInputVal: ")
  62. (insert ( format "\newcommand{\c%s}{\mathcal %s}" inputval inputval) )
  63. )
Add Comment
Please, Sign In to add comment