Paste
#79117: Untitled ASCII paste by 115.60.174.234
(defun wy-construct-arg-list (str sep)
"Construct a list from a string. Using sep as separetor."
(interactive)
(let* ((result nil)
(add-to-the-list
(lambda (x)
(setq result (cons x result)))))
(let loop ((s "")
(left str)
(ptr 0))
(setq nextchar (substring left 0 1))
(print s)
(catch 'exit
(cond ((and
(string-match "\\s" nextchar)
(> (length s) 0))
(add-to-the-list s)
(setq s ""))
((= (+ 1 ptr) (length str))
(setq s (concat s nextchar))
(if (> (length s) 0) (add-to-the-list s))
(throw 'exit))
(t
(setq s (concat s nextchar))))
(loop s (substring left 1) (+ ptr 1))))
(reverse result)))
;; startup programs
(defun wy-start-entry (prog-entry)
(interactive)
(let ((process (make-process standard-output))
(prog-entry-list (wy-construct-arg-list prog-entry "\\s")))
(apply start-process process (car prog-entry-list) (cdr prog-entry-list))))
(setq startup-programs
'("feh --bg-scale /home/wzlxx/pictures/backgrounds/mac/bg005.jpg"
"xterm"
"/home/wzlxx/.yong/yong -d"
"setxkbmap -option ctrl:swapcaps"))
(defun wy-start-up (programs)
(wy-start-entry programs))
(mapc wy-start-up startup-programs)
(defun wy-cleanup-on-exit ()
(mapc stop-process (active-processes)))
(add-hook 'before-exit-hook 'wy-cleanup-on-exit)