1 |
;;; erbc.el --- Erbot user-interface commands -- see also erbc5.el |
;;; erbc.el --- Erbot user-interface commands -- see also erbc5.el |
2 |
;; Time-stamp: <2005-08-11 20:29:52 deego> |
;; Time-stamp: <2005-09-02 14:48:11 deego> |
3 |
;; Copyright (C) 2002 D. Goel |
;; Copyright (C) 2002 D. Goel |
4 |
;; Emacs Lisp Archive entry |
;; Emacs Lisp Archive entry |
5 |
;; Filename: erbc.el |
;; Filename: erbc.el |
271 |
(when (and (null key) (null args)) |
(when (and (null key) (null args)) |
272 |
(setq key "")) |
(setq key "")) |
273 |
(unless (stringp key) |
(unless (stringp key) |
274 |
|
;; is this safe? what about properties? |
275 |
(setq key (read-kbd-macro |
(setq key (read-kbd-macro |
276 |
(mapconcat '(lambda (arg) (format "%s" arg)) |
(mapconcat '(lambda (arg) (format "%s" arg)) |
277 |
(cons key args) |
(cons key args) |
408 |
(let* ((f function) |
(let* ((f function) |
409 |
g |
g |
410 |
) |
) |
411 |
(if (stringp f) |
(when (stringp f) |
412 |
(setq f (read f))) |
(setq f (erbn-read f))) |
413 |
(cond |
(cond |
414 |
((symbolp f) |
((symbolp f) |
415 |
(progn |
(progn |
417 |
g |
g |
418 |
(cond |
(cond |
419 |
((fboundp f) f) |
((fboundp f) f) |
420 |
(t (read (concat "fs-" (format "%s" f)))))) |
(t (erbn-read (concat "fs-" (format "%s" f)))))) |
421 |
(unless (fboundp g) |
(unless (fboundp g) |
422 |
(setq g f)) |
(setq g f)) |
423 |
(let* ((def (symbol-function g))) |
(let* ((def (symbol-function g))) |
432 |
(describe-function g) |
(describe-function g) |
433 |
(describe-function g)) |
(describe-function g)) |
434 |
|
|
435 |
))) |
))) ;; if list, DO NOT wanna eval it--> |
|
;; if list, DO NOT wanna eval it--> |
|
436 |
(t |
(t |
437 |
"NO function specified")))) |
"NO function specified")))) |
438 |
|
|
448 |
(str3 "") |
(str3 "") |
449 |
) |
) |
450 |
(cond |
(cond |
451 |
((stringp function) (setq function (read function))) |
((stringp function) (setq function (erbn-read function))) |
452 |
(t nil)) |
(t nil)) |
453 |
(cond |
(cond |
454 |
((null function) (format "Sorry, %s is not a symbol" function)) |
((null function) (format "Sorry, %s is not a symbol" function)) |
457 |
(setq str2 |
(setq str2 |
458 |
(with-temp-buffer |
(with-temp-buffer |
459 |
(where-is function t) |
(where-is function t) |
460 |
(buffer-string))) |
(erbutils-buffer-string))) |
461 |
(concat str0 str1 str2 str3)) |
(concat str0 str1 str2 str3)) |
462 |
(t (format "Looks like %s is not a symbol" function))))) |
(t (format "Looks like %s is not a symbol" function))))) |
463 |
|
|
476 |
(unless variable (error "Syntax: , dv 'variable")) |
(unless variable (error "Syntax: , dv 'variable")) |
477 |
(let* ((f variable)) |
(let* ((f variable)) |
478 |
(if (stringp f) |
(if (stringp f) |
479 |
(setq f (read f))) |
(setq f (erbn-read f))) |
480 |
(cond |
(cond |
481 |
((symbolp f) |
((symbolp f) |
482 |
(erbutils-describe-variable f)) |
(erbutils-describe-variable f)) |
494 |
or dv works fine..Actually, df knows how to load unloaded features |
or dv works fine..Actually, df knows how to load unloaded features |
495 |
automatically." |
automatically." |
496 |
(if (stringp feature) |
(if (stringp feature) |
497 |
(setq feature (read feature))) |
(setq feature (fsi-read feature))) |
498 |
(when (or (string-match "/" (format "%s" feature)) |
(when (or (string-match "/" (format "%s" feature)) |
499 |
(string-match "\\\\" (format "%s" feature))) |
(string-match "\\\\" (format "%s" feature))) |
500 |
(error "Your safety is VERY important to us, so we avoid loading features containing slashes.")) |
(error "Your safety is VERY important to us, so we avoid loading features containing slashes.")) |
916 |
(newmsglist nil) |
(newmsglist nil) |
917 |
(msgstr (erbutils-stringify msg)) |
(msgstr (erbutils-stringify msg)) |
918 |
;(newstrmsg nil) |
;(newstrmsg nil) |
919 |
(lispmsg (read msgstr) |
(lispmsg (erbn-read msgstr) |
920 |
)) |
)) |
921 |
|
|
922 |
|
|
978 |
;;(mapcar 'intern (cdr msg)))) |
;;(mapcar 'intern (cdr msg)))) |
979 |
;;(read (cons (intern (first msg)) |
;;(read (cons (intern (first msg)) |
980 |
;; (read (list (erbutils-stringify (cdr msg)))))) |
;; (read (list (erbutils-stringify (cdr msg)))))) |
981 |
(read (concat "( "(erbutils-stringify msg) " )")))) |
(fsi-read (concat "( "(erbutils-stringify msg) " )")))) |
982 |
|
|
983 |
((equal 0 |
((equal 0 |
984 |
(string-match "\\(s\\|r\\)/" (first msg))) |
(string-match "\\(s\\|r\\)/" (first msg))) |
1159 |
(progn |
(progn |
1160 |
(unless (stringp tmpv) (setq tmpv (format "%s" |
(unless (stringp tmpv) (setq tmpv (format "%s" |
1161 |
tmpv))) |
tmpv))) |
1162 |
(not (integerp (ignore-errors (read tmpv)))))))) |
(not (integerp (ignore-errors (erbn-read tmpv)))))))) |
1163 |
;;(setq searchp t) |
;;(setq searchp t) |
1164 |
(setq mainterm |
(setq mainterm |
1165 |
(concat mainterm ".*" tmpv)) |
(concat mainterm ".*" tmpv)) |
1304 |
|
|
1305 |
(defun fsi-eval-or-say (str &optional fs-victim) |
(defun fsi-eval-or-say (str &optional fs-victim) |
1306 |
(let ((aa (when (stringp str) |
(let ((aa (when (stringp str) |
1307 |
(ignore-errors (read str))))) |
(ignore-errors (erbn-read str))))) |
1308 |
(cond |
(cond |
1309 |
((consp aa) |
((consp aa) |
1310 |
(unless fs-victim (setq fs-victim fs-nick)) |
(unless fs-victim (setq fs-victim fs-nick)) |
1471 |
(replace-string prefix "") |
(replace-string prefix "") |
1472 |
(text-mode) |
(text-mode) |
1473 |
(fill-paragraph 1) |
(fill-paragraph 1) |
1474 |
(read (buffer-substring (point-min) (point-max)))))) |
(erbn-read (buffer-substring (point-min) (point-max)))))) |
1475 |
shortnames)) |
shortnames)) |
1476 |
|
|
1477 |
(defun fsi-commands (&optional regexp N M &rest foo) |
(defun fsi-commands (&optional regexp N M &rest foo) |
1959 |
) |
) |
1960 |
|
|
1961 |
(if (stringp N) |
(if (stringp N) |
1962 |
(setq N (read N))) |
(setq N (erbn-read N))) |
1963 |
(unless (integerp N) |
(unless (integerp N) |
1964 |
(setq N 0)) |
(setq N 0)) |
1965 |
(if (stringp M) |
(if (stringp M) |
1966 |
(setq M (read M))) |
(setq M (erbn-read M))) |
1967 |
(if (and (integerp M) (= M N)) |
(if (and (integerp M) (= M N)) |
1968 |
(setq M (+ N 1))) |
(setq M (+ N 1))) |
1969 |
(setq records |
(setq records |
2075 |
) |
) |
2076 |
(setq foo (fs-correct-entry foo)) |
(setq foo (fs-correct-entry foo)) |
2077 |
(if (stringp N) |
(if (stringp N) |
2078 |
(setq N (read N))) |
(setq N (erbn-read N))) |
2079 |
(unless (integerp N) |
(unless (integerp N) |
2080 |
(setq N 0)) |
(setq N 0)) |
2081 |
(if (stringp M) |
(if (stringp M) |
2082 |
(setq M (read M))) |
(setq M (erbn-read M))) |
2083 |
(if (and (integerp M) (= M N)) |
(if (and (integerp M) (= M N)) |
2084 |
(setq M (+ N 1))) |
(setq M (+ N 1))) |
2085 |
(unless (stringp foo) |
(unless (stringp foo) |
2089 |
foo |
foo |
2090 |
)) |
)) |
2091 |
(result1 (and (stringp result0) |
(result1 (and (stringp result0) |
2092 |
(ignore-errors (read result0)))) |
(ignore-errors (erbn-read result0)))) |
2093 |
(len (length result1)) |
(len (length result1)) |
2094 |
(newM (if (and (integerp M) |
(newM (if (and (integerp M) |
2095 |
(< M len)) |
(< M len)) |
2332 |
Numbering of positions starts from 0. " |
Numbering of positions starts from 0. " |
2333 |
(unless term (error "Syntax: , N->M in TERM (no term found)")) |
(unless term (error "Syntax: , N->M in TERM (no term found)")) |
2334 |
(when (stringp from) |
(when (stringp from) |
2335 |
(setq from (read from))) |
(setq from (erbn-read from))) |
2336 |
(when (stringp to) |
(when (stringp to) |
2337 |
(setq to (read to))) |
(setq to (erbn-read to))) |
2338 |
(unless (stringp term) |
(unless (stringp term) |
2339 |
(setq term (format "%s" term))) |
(setq term (format "%s" term))) |
2340 |
(let* |
(let* |
2341 |
((exactnotes (erbbdb-get-exact-notes term)) |
((exactnotes (erbbdb-get-exact-notes term)) |
2342 |
(realterm (erbbdb-get-exact-name term)) |
(realterm (erbbdb-get-exact-name term)) |
2343 |
(notes (and (stringp exactnotes ) (read exactnotes))) |
(notes (and (stringp exactnotes ) (erbn-read exactnotes))) |
2344 |
(len (length notes)) |
(len (length notes)) |
2345 |
(max (- len 1)) |
(max (- len 1)) |
2346 |
(newnotes notes) |
(newnotes notes) |
2400 |
(numstring |
(numstring |
2401 |
(entries0 (erbbdb-get-exact-notes name)) |
(entries0 (erbbdb-get-exact-notes name)) |
2402 |
(entries (and (stringp entries0 ) |
(entries (and (stringp entries0 ) |
2403 |
(ignore-errors (read entries0)))) |
(ignore-errors (erbn-read entries0)))) |
2404 |
(len (length entries))) |
(len (length entries))) |
2405 |
|
|
2406 |
(unless entries |
(unless entries |
2409 |
(setq number 0)) |
(setq number 0)) |
2410 |
(setq numstring (downcase (format "%s" number))) |
(setq numstring (downcase (format "%s" number))) |
2411 |
(when (stringp number) |
(when (stringp number) |
2412 |
(setq number (read number))) |
(setq number (erbn-read number))) |
2413 |
(unless (integerp number) (setq number nil)) |
(unless (integerp number) (setq number nil)) |
2414 |
(unless |
(unless |
2415 |
(or number |
(or number |
2588 |
(progn |
(progn |
2589 |
(let* ((fir (first args)) |
(let* ((fir (first args)) |
2590 |
(aa (erbbdb-get-exact-notes fir)) |
(aa (erbbdb-get-exact-notes fir)) |
2591 |
(notes (and (stringp aa) (read aa))) |
(notes (and (stringp aa) (erbn-read aa))) |
2592 |
(len (length notes))) |
(len (length notes))) |
2593 |
(when (= len 0) |
(when (= len 0) |
2594 |
(error "There's no such term %s. Use , %s is ..." fir fir)) |
(error "There's no such term %s. Use , %s is ..." fir fir)) |
2955 |
(goto-char (point-min)) |
(goto-char (point-min)) |
2956 |
(let ((fill-column fs-internal-fill-column)) |
(let ((fill-column fs-internal-fill-column)) |
2957 |
(fill-paragraph nil)) |
(fill-paragraph nil)) |
2958 |
(buffer-string))) |
(erbutils-buffer-string))) |
2959 |
(t "\n"))) |
(t "\n"))) |
2960 |
(defun fsi-dunnet-mode (&optional arg) |
(defun fsi-dunnet-mode (&optional arg) |
2961 |
|
|
3251 |
"Show the apropos-matches of regexp starting at match number N" |
"Show the apropos-matches of regexp starting at match number N" |
3252 |
(unless regexp |
(unless regexp |
3253 |
(error "Syntax: , apropos REGEXP &optional N M")) |
(error "Syntax: , apropos REGEXP &optional N M")) |
3254 |
(if (stringp N) (setq N (read N))) |
(if (stringp N) (setq N (erbn-read N))) |
3255 |
(unless (integerp N) (setq N 0)) |
(unless (integerp N) (setq N 0)) |
3256 |
(unless (stringp regexp) |
(unless (stringp regexp) |
3257 |
(setq regexp (format "%s" regexp))) |
(setq regexp (format "%s" regexp))) |
3282 |
|
|
3283 |
(defun fsi-find-variable-internal (function &optional nolimitp &rest ignore) |
(defun fsi-find-variable-internal (function &optional nolimitp &rest ignore) |
3284 |
"Finds the variable named FUNCTION." |
"Finds the variable named FUNCTION." |
3285 |
(if (stringp function) (setq function (read function))) |
(if (stringp function) (setq function (erbn-read function))) |
3286 |
(cond |
(cond |
3287 |
((symbolp function) |
((symbolp function) |
3288 |
(unless (boundp function) |
(unless (boundp function) |
3330 |
(unless function |
(unless function |
3331 |
(error |
(error |
3332 |
"Syntax: (ff 'fucntion)")) |
"Syntax: (ff 'fucntion)")) |
3333 |
(if (stringp function) (setq function (read function))) |
(if (stringp function) (setq function (erbn-read function))) |
3334 |
(cond |
(cond |
3335 |
((symbolp function) |
((symbolp function) |
3336 |
(unless (fboundp function) |
(unless (fboundp function) |
3435 |
mainterm |
mainterm |
3436 |
)) |
)) |
3437 |
(result1 (and (stringp result0) |
(result1 (and (stringp result0) |
3438 |
(ignore-errors (read result0)))) |
(ignore-errors (erbn-read result0)))) |
3439 |
(len (length result1))) |
(len (length result1))) |
3440 |
(cond |
(cond |
3441 |
;; in cond0 |
;; in cond0 |
3556 |
(setq num |
(setq num |
3557 |
(if (numberp fir) |
(if (numberp fir) |
3558 |
fir |
fir |
3559 |
(ignore-errors (read fir))))) |
(ignore-errors (erbn-read fir))))) |
3560 |
(if (numberp num) |
(if (numberp num) |
3561 |
(setq args (cdr args)) |
(setq args (cdr args)) |
3562 |
(setq num 1)) |
(setq num 1)) |
3646 |
|
|
3647 |
(defun fsi-cp (name dest) |
(defun fsi-cp (name dest) |
3648 |
(let* ((exn (erbbdb-get-exact-notes name)) |
(let* ((exn (erbbdb-get-exact-notes name)) |
3649 |
(notes (and (stringp exn) (read exn)))) |
(notes (and (stringp exn) (erbn-read exn)))) |
3650 |
(unless notes |
(unless notes |
3651 |
(error "No such term %s" name)) |
(error "No such term %s" name)) |
3652 |
(when (erbbdb-get-exact-notes dest) |
(when (erbbdb-get-exact-notes dest) |
3658 |
(defun fsi-notes (name) |
(defun fsi-notes (name) |
3659 |
"Internal. Return the notes as a list. " |
"Internal. Return the notes as a list. " |
3660 |
(let ((exnotes (erbbdb-get-exact-notes name))) |
(let ((exnotes (erbbdb-get-exact-notes name))) |
3661 |
(and (stringp exnotes) (read exnotes)))) |
(and (stringp exnotes) (erbn-read exnotes)))) |
3662 |
|
|
3663 |
|
|
3664 |
|
|
3826 |
(setq sr |
(setq sr |
3827 |
(if (equal 0 (string-match "s" (first remmsg))) "s" "r")) |
(if (equal 0 (string-match "s" (first remmsg))) "s" "r")) |
3828 |
(setq las (first (last remmsg))) |
(setq las (first (last remmsg))) |
3829 |
(setq number (and (stringp las) (read las))) |
(setq number (and (stringp las) (erbn-read las))) |
3830 |
(if (or (numberp number) |
(if (or (numberp number) |
3831 |
(equal 0 (string-match |
(equal 0 (string-match |
3832 |
"all" |
"all" |
3842 |
|
|
3843 |
(when termcheckp |
(when termcheckp |
3844 |
(let* ((exn (erbbdb-get-exact-notes term)) |
(let* ((exn (erbbdb-get-exact-notes term)) |
3845 |
(notes (and (stringp exn) (read exn))) |
(notes (and (stringp exn) (erbn-read exn))) |
3846 |
(len (length notes))) |
(len (length notes))) |
3847 |
(if (> len 1) |
(if (> len 1) |
3848 |
(throw 'erbnocmd-repl-error |
(throw 'erbnocmd-repl-error |
3955 |
(setq number (format "%s" number)) |
(setq number (format "%s" number)) |
3956 |
(let* |
(let* |
3957 |
((exactnotes (erbbdb-get-exact-notes term)) |
((exactnotes (erbbdb-get-exact-notes term)) |
3958 |
(notes (and (stringp exactnotes) (read exactnotes))) |
(notes (and (stringp exactnotes) (erbn-read exactnotes))) |
3959 |
(len (length notes)) |
(len (length notes)) |
3960 |
newnotes |
newnotes |
3961 |
newnote |
newnote |
3962 |
(lenargs (length arglist)) |
(lenargs (length arglist)) |
3963 |
(initargs (subseq arglist 0 (- lenargs 1))) |
(initargs (subseq arglist 0 (- lenargs 1))) |
3964 |
(finargs (first (last arglist))) |
(finargs (first (last arglist))) |
3965 |
(numnum (read number)) |
(numnum (erbn-read number)) |
3966 |
) |
) |
3967 |
(when (and (null number) (= len 1)) (setq number 0)) |
(when (and (null number) (= len 1)) (setq number 0)) |
3968 |
(unless exactnotes (error "No such term: %S" term)) |
(unless exactnotes (error "No such term: %S" term)) |
4106 |
|
|
4107 |
(defun fsi-channel-members (&optional n m &rest args) |
(defun fsi-channel-members (&optional n m &rest args) |
4108 |
(when (stringp n) |
(when (stringp n) |
4109 |
(setq n (ignore-errors (read n)))) |
(setq n (ignore-errors (erbn-read n)))) |
4110 |
(when (stringp m) |
(when (stringp m) |
4111 |
(setq m (ignore-errors (read m)))) |
(setq m (ignore-errors (erbn-read m)))) |
4112 |
(unless (integerp n) (setq n 0)) |
(unless (integerp n) (setq n 0)) |
4113 |
(unless (integerp m) (setq m nil)) |
(unless (integerp m) (setq m nil)) |
4114 |
(subseq (fs-channel-members-all) n m)) |
(subseq (fs-channel-members-all) n m)) |
4830 |
;; (buffer-string)).. and cause a huge uservariables file.. |
;; (buffer-string)).. and cause a huge uservariables file.. |
4831 |
|
|
4832 |
(defun fsi-buffer-string (&rest args) |
(defun fsi-buffer-string (&rest args) |
4833 |
(buffer-string-no-properties (point-min) (point-max))) |
(buffer-substring-no-properties (point-min) (point-max))) |
4834 |
|
|
4835 |
(defalias 'fsi-buffer-substring 'buffer-substring-no-properties) |
(defalias 'fsi-buffer-substring 'buffer-substring-no-properties) |
4836 |
|
|
5039 |
Note: Used by fs-describe" |
Note: Used by fs-describe" |
5040 |
(cond |
(cond |
5041 |
((stringp arg) |
((stringp arg) |
5042 |
(condition-case fs-tmp (read arg) |
(condition-case fs-tmp (erbn-read arg) |
5043 |
(error arg))) |
(error arg))) |
5044 |
(t arg))) |
(t arg))) |
5045 |
|
|
5046 |
|
|
5047 |
(defun fsi-read (str) |
(defun erbn-read-from-string (str) |
5048 |
|
(let (str2) |
5049 |
(cond |
(cond |
5050 |
((stringp str) |
((stringp str) |
5051 |
(read str)) |
(setq str2 (copy-sequence str)) |
5052 |
(t (error "The bot will only read from strings. ")))) |
(set-text-properties 0 (length str2) nil str2) |
5053 |
|
(read-from-string str)) |
5054 |
|
(t (error "The bot will only read from strings. "))))) |
5055 |
|
|
5056 |
|
|
5057 |
|
|
5058 |
|
(defun erbn-read (str) |
5059 |
|
"Like read, but only from strings" |
5060 |
|
(car (erbn-read-from-string str))) |
5061 |
|
|
5062 |
|
|
5063 |
|
(defalias 'fsi-read 'erbn-read) |
5064 |
|
(defalias 'fsi-read-from-string 'erbn-read-from-string) |
5065 |
|
|
5066 |
|
|
5067 |
(erbutils-defalias-i |
(erbutils-defalias-i |