picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

eedit.l (5243B)


      1 # 29nov12tj
      2 # Authors Alexander Burger, Thorsten Joltiz
      3 # (c) Software Lab. Alexander Burger
      4 
      5 # "*F" "*Lst" "*X" "*K"
      6 
      7 #{ 
      8 
      9 * Emacs Server
     10 
     11 ** Start the Emacs server you want to use for PicoLisp editing with
     12 server-name 'server', only then it will be automatically recognized by
     13 the calls to emacsclient. Example shellscript 'emacsd' for starting
     14 emacs as daemon (make it executable):
     15 
     16  ,------------------------------------------------
     17  | -rwxr-xr-x 1 me users   83 12. Nov 12:27 emacsd
     18  `------------------------------------------------
     19 
     20 ,-----------------------------------------------
     21 | #!/bin/sh
     22 | 
     23 | exec emacs --daemon=server  -l  ~/my/home/emacs/init.el
     24 `-----------------------------------------------
     25 
     26 If there is no Emacs server running, or none with server-name
     27 'server', the call to emacsclient will start a new server and open an
     28 emacsclient for this server.
     29 
     30 * Customize Emacs:
     31 
     32 ** Make Emacs revert the edit-buffers without querying
     33 (see http://www.gnu.org/software/emacs/manual/html_node/elisp/Reverting.html)
     34 
     35 ,--------------------------------------------------------------------
     36 | You can customize how revert-buffer does its work by setting the
     37 | variables described in the rest of this section. 
     38 | 
     39 | — User Option: revert-without-query
     40 | 
     41 | This variable holds a list of files that should be reverted without
     42 | query. The value is a list of regular expressions.
     43 `--------------------------------------------------------------------
     44 
     45 Use a regexp like this, replacing 'my/home/directory/' with the path
     46 to your home directory:
     47 
     48 ,-------------------------------
     49 | my/home/directory/\.pil/tmp/.+
     50 `-------------------------------
     51 
     52 ** Make Emacs save the edited buffer on exit without querying
     53 
     54 Do not exit with "C-x #" (server-edit) but with "C-x C-c" or "C-u C-x
     55 C-c":
     56 
     57 ,---------------------------------------------------------------------
     58 | (save-buffers-kill-terminal &optional ARG)
     59 | 
     60 | Offer to save each buffer, then kill the current connection.
     61 | If the current frame has no client, kill Emacs itself.
     62 | 
     63 | With prefix ARG, silently save all file-visiting buffers, then kill.
     64 | 
     65 | If emacsclient was started with a list of filenames to edit, then
     66 | only these files will be asked to be saved.
     67 `---------------------------------------------------------------------
     68 
     69 ** Put the edited buffer into PicoLisp Mode 
     70 
     71 The PicoLisp distribution contains a PicoLisp major mode for Emacs,
     72 'picolisp.el' in the "el/" directory (that is "@lib/el" for a local
     73 installation, or some system dependent directory for a global installation).
     74 Make sure that you load this file on Emacs startup and automatically put '.l'
     75 files into picolisp-mode, e.g. with the following code in you .emacs:
     76 
     77 ,------------------------------------------------------------
     78 | (add-to-list 'load-path "~/path/to/picolisp/lib/el/")
     79 | (require 'picolisp)
     80 | (add-to-list 'auto-mode-alist '("\\.l\\'" . picolisp-mode))
     81 `------------------------------------------------------------
     82 
     83 ** Add and remove symbols from the 'edit' buffer
     84 
     85 With point on a symbol (or with a symbol marked as region in transient
     86 mark mode), 'C-c C-v' (picolisp-edit-K) adds this symbol on top of the
     87 editing buffer. A subsequent 'C-c C-c' (picolisp-edit-Q) removes it
     88 again and puts point back to its previous line. Using 'C-c C-c' when
     89 only one symbol is left exits the 'edit' buffer.
     90 
     91  }#
     92 
     93 
     94 (de edit @
     95    (let *Dbg NIL
     96       (setq "*F" (tmp '"edit.l"))
     97       (catch NIL
     98          ("edit" (rest)) ) ) )
     99 
    100 (de "edit" ("Lst")
    101    (let "N" 1
    102       (loop
    103          (out "*F"
    104             (setq "*Lst"
    105                (make
    106                   (for "S" "Lst"
    107                      ("loc" (printsp "S"))
    108                      ("loc" (val "S"))
    109                      (pretty (val "S"))
    110                      (prinl)
    111                      (for "X" (sort (getl "S"))
    112                         ("loc" "X")
    113                         (space 3)
    114                         (if (atom "X")
    115                            (println "X" T)
    116                            (printsp (cdr "X"))
    117                            (pretty (setq "X" (car "X")) -3)
    118                            (cond
    119                               ((type "X")
    120                                  (prin "  # ")
    121                                  (print @) )
    122                               ((>= 799999 "X" 700000)
    123                                  (prin "  # " (datStr "X")) ) )
    124                            (prinl) ) )
    125                      (prinl)
    126                      (println '(********))
    127                      (prinl) ) ) ) )
    128          (call 'emacsclient
    129             "-a" ""
    130             "-c"
    131             (pack "+" "N")
    132             "*F" )
    133          (apply ==== "*Lst")
    134          (in "*F"
    135             (while (and (setq "*X" (read)) (atom "*X"))
    136                (def "*X" (read))
    137                (until (= '(********) (setq "*K" (read)))
    138                   (def "*X" "*K" (read)) ) ) )
    139          (====)
    140          (NIL "*X" (throw))
    141          (T (=0 (car "*X")))
    142          (setq "N" (car "*X"))
    143          ("edit" (conc (cdr "*X") "Lst")) ) ) )
    144 
    145 (de "loc" ("X" "Lst")
    146    (cond
    147       ((memq "X" "Lst"))
    148       ((and (str? "X") (not (memq "X" (made))))
    149          (link "X") )
    150       ((pair "X")
    151          (push '"Lst" "X")
    152          ("loc" (car "X") "Lst")
    153          ("loc" (cdr "X") "Lst") ) ) )