-*- mode: org; coding: utf-8; -*-

#+TITLE: What's left to do?
#+STARTUP: content hidestars

* Finish `untangle/unweb' work
In 0.3 Noweb was removed; the code was split into pure Guile scheme
source code and separate texinfo documentation.  This setup is now
functional and needs lots of work and cleaning up.

* Cleanup examples
Run GNU indent, use struct_ref etc (see Guimax) instead of `wud*2'.
Also see guimax branch @ https://gitlab.com/janneke/emacsy-webkit-gtk

* Self-doc/help system
Figure out the status of self-doc.scm and help.scm, how this works, add
C-h f, references to code, etc.

* Cleanout and prioritize OLD Emacsy TODO

* OLD Emacsy TODO
  - [X] Defining variables with define-variable leaves warnings about
    that variable not being defined. FIXED. Thanks, Mark Weaver!
  - [ ] Change emacsy-key-event to emacsy-submit-key-event or something.
  - [ ] rename define-cmd to define-command
  - [ ] BUG: The frame title should show the current buffer whereas the
    modeline show's the window's buffer
  - [ ] hello-emacsy BUG: C-u 1 0 doesn't show latest character.
  - [ ] It'd be nice to have a for-each which didn't use lambdas and
    was more like loop.  The for-each action list where action can be
    long then the list that it operates on is kind of jaring.)
  - [ ] Maybe there should be hook such that a REPL can be invoked
    from within Emacsy that then in the simplest case reports the port
    and hostname. Or perhaps invokes Emacs to enter it.
  - [X] How to implement defvar: Use [[http://www.gnu.org/software/guile/manual/guile.html#Object-Properties][object-properties]] on the variable
    from (module-variable). Thanks, Andy!
  - [X] Incorporating modifier keys should be easy.  Split <key-event>
    into <modifier-key-event> and <key-event.
  - [X] Need to pick up modifier-keys from GLFW.
  - [X] Remove (kbd "C-...") It's useless noise.
  - [X] Need to fix history.  Just make an indexable list class.
    - [X] cursor-list now exists.

  - How to make a trampoline out of a symbol, by mark_weaver:

  (define (make-trampoline s)
                    (compile `(lambda () (,s)) #:env
                    <desired-module>))

   here's an implementation of 'make-trampoline' that uses vastly less
   memory per trampoline, and avoids loading the compiler: (define
   (make-trampoline module name) (let ((var (module-variable module
   name))) (lambda () ((variable-ref var)))))

  - [ ] Come up with a way to export commands so that one can indicate
    what modules one wants to use.

    1. Let the user do it by creating their own modules.

       Nice idea because it requires no new infrastructure.  Might
       encourage the proliferation of new modules.

    2. Let the user export certain symbols as commands.  Pretty much
       like a new kind of public interface.

       Requires some infrastructure.  Possibly want to use this
       generally to collect up all kinds of other things.  So far I've
       had commands and fitness functions.  Other things might come
       along as well.

       (export-commands this that yon)

       (emacsy-export commands '(this that yon))

       (emacsy-export fitness-function '(this that yon))

       %emacsy-local-modules


    3. Do what I'm doing now where the user has to define their name
       for something.

    4. Just make a list of the symbols.  Nothing fancy.  If someone
       wants only the commands, they do this:

   (resolve-interface '(that-module) #:select (@ (that-module) commands))

   (resolve-interface '(that-module %command)

   (use-modules ((that-module) #:select (@commands))


  - [ ] rename read-file-name to EITHER read-filename OR
    read-filename-from-minibuffer
  - [ ] have backtraces go to logs
  - [X] Rethink the commands. Can't we keep them as simple lambdas?
    Do we have to wrap them?

    Also, when the user provides the symbol of a function, let's
    create a trampoline to that function.  Otherwise, if they provide
    a lambda, run that lambda.

  - [X] If module (emacsy emacsy) does not load, it may be because it did
    not compile. Please show the correct error. FIXED.
  - [X] Make the read-from-minibuffer accept a symbol for a history
  - [X] Turn history into an object/record rather than a list and an
    index.  Need a list with a cursor or a zipper; can use 2 lists for
    what's in front and behind the current position.
  - [ ] Rename EY_* C macros to EMACSY_SAME_NAME_AS_SCHEME_OK_P
  - [X] Make the default read-from-minibuffer history symbol be (what-command-am-i)
  - [-] Add a couple of variations on the webkit browser
    - [X] make it use multiple buffers
    - [ ] make it use multiple windows
  - [ ] Should (emacsy window) always be loaded but default to not
    supporting multiple windows?

  - [ ]

  - [ ] get rid of noise in emacsy (noise?) log noise?
  - [ ] Change define-cmd to define-command
  - [ ] implement coroutines in Guile using [[http://www.lua.org/manual/5.2/manual.html][Lua API]] and [[http://wingolog.org/archives/2011/08/30/the-gnu-extension-language][this]] as a basis
    It'd be nice if the coroutines were interruptable.  Maybe [[http://lists.gnu.org/archive/html/guile-user/2011-10/msg00038.html][this would help.]]
    This is a [[http://pllab.is.ocha.ac.jp/~asai/cw2011tutorial/main-e.pdf][good tutorial]] on shift and reset.

    Commands should be marked as suspendable.  Suspendable commands
    will be executed in their own coroutine that may be suspended,
    resumed, resumed in the background, or killed.  This is similar to
    the split between builtin commands in shell and regular commands.
    God, this is going to be COOL!


  - [X] make debugging work in emacsy
    Getting better with debug-on-error?
  - [ ] fix kill of all buffers bug
  - [X] add universal argument C-u
  - [ ] clear the echo area once other messages start to come.
  - [X] figure out how to integrate a browser window, it'll show pdf
    graphs, images, etc. too!
  - [X] there should be a way to turn off the display/runloop from
    happening.  Or maybe not. Maybe the batch-mode or non-interactive
    mode for Emacsy shouldn't include Emacsy at all.  It should just
    be regular Guile that one reverts to.  This has the added
    advantage that one ends up creating Guile modules that others can
    use.
  - [ ] Add re-export-module macro, and do it as you build everything up.
  - [ ] (define (get-cid) (yield (lambda (resume) (resume (coroutine->cid resume)))))
  - [ ] make emacsy work with copy/paste [[http://stackoverflow.com/questions/6888862/how-to-access-clipboard-data-programmatically][link]]

  - [ ] Have something for blocking reading, need something for
    blocking/smartly doing writing (message) shouldn't cause an
    enormous hassle for unit testing like it does now.

  - [ ] [[https://github.com/technomancy/find-file-in-project/blob/master/find-file-in-project.el][Try this find-file-in-project]]
  - [[https://groups.google.com/forum/m/?fromgroups#!msg/comp.emacs/j_fNPgtbavM/DVygGrzgQgMJ][Great introduction]] to the bare minimum you need to know to use
    Emacs
  - How to make [[http://www.gnu.org/software/guile/docs/docs-2.0/guile-ref/Identifier-Macros.html#Identifier-Macros][variable aliases]]
  - Note: the noweb filter docs2comments does not work with noweb's line pragmas
  - how to do [[https://github.com/davexunit/gnumaku/blob/rebirth/gnumaku/coroutine.scm][coroutines]] in guile
  - [ ] How do syscalls work when Emacsy is in batch mode?

    Populate event buffer from file handle?  Are syscalls even required
    if we're not in interactive mode?
  - [X] In order to terminate potential rogue coroutines, I could set
    a posix alarm that runs every second or so to check the events.
  - Readline already offers some completion functions for files
    and defines.
  http://www.gnu.org/software/guile/manual/guile.html#Readline-Functions
  - [[http://ergoemacs.org/emacs/emacs_modernization.html][Emacs modernization]] may have some good ideas to apply to Emacsy
  - [ ] How to test Emacsy interactions?  It should accept a filehandle that
    specifies events and plays them back like a macro.
  - [[http://cygwin.com/ml/guile-emacs/2000-q2/msg00029.html][These folks]] are thinking similarly about how to deal with
    commands running in the background
  - [X] Change shebang lines from #!/usr/bin/env perl to #!@PERL@ etc.
  - [ ] configure.ac needs to deal with the case where no hello-emacsy
    is available.
  - [X] GLUT needs to be checked at configure time on other OSes.
  - An interesting way to [[http://lists.gnu.org/archive/html/guile-user/2011-10/msg00038.html][debug at the prompt]] in Guile
  - [ ] Use DBus as a way to interoperate between Emacsy applications.
  - [ ] Swap out blocking module for either ethreads or another
    general continuation method.
  - [ ] Fix bug with (define-interactive name (let ((x 1)) (lambda () (incr! x))))
  - [ ] Fix bug with define-interactive not using documentation strings.
  - [ ] Idea: Maybe create an eshell like mode where the BNF from bash
    is used as a command mode for scheme. shelly? gash? bashy?
  - [ ] Integrate noweb into guile, such that guile will run off noweb
    files. Guile [[http://draketo.de/light/english/wisp-lisp-indentation-preprocessor#v0.5-repl][wisp]] already shows how to do it.
** Trying to rework block code into something more malleable.
(define* (wait #:optional (delay 1))
  "Yield coroutine and schdule the continuation to be run after DELAY
ticks."
  (yield (lambda (resume) (agenda-schedule resume delay))))

(define* (suspend)
  "Yield coroutine and schdule the continuation to be run after DELAY
ticks."
  (yield (lambda (resume) (agenda-schedule resume delay))))

(foreground) must happen outside the coroutine.

(define-command (suspend)
  (cosignal 'suspend foreground-cid))

(define-command (interrupt)
  (cosignal 'interrupt foreground-cid))

(define (cosignal sig cid)
  ((cid->resume cid) 'signal
(case sig
    ((kill)
     (lambda () (coexit -1)))
    ((suspend)
     (lambda () ()))
    ((continue)
     (lambda () ()))

)
))

(define (coexit code)
  (yield (lambda (resume) code)))

(define (coexit . args)
  (yield (lambda (resume) (apply values args)))

cid <-> coroutine



(cowait cid-1 cid-2)

Does suspend happen inside or outside the coroutine?  Signals happened
from outside the process in unix.

* legalese
Copyright © 2012, 2013 Shane Celis <shane.celis@gmail.com>
Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>

  Copying and distribution of this file, with or without modification,
  are permitted in any medium without royalty provided the copyright
  notice and this notice are preserved.
