gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fpscalc mode


From: Emanuel Berg
Subject: fpscalc mode
Date: Sat, 05 Oct 2013 00:45:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

OK, I'll just yank the README file - but, check out the
screenshots (URLs *last*) if you are impatient: probably
they will tell you as much as this entire document.

If you, from a point of more experience than mine, have
comments how to improve the mode, please share, but
don't forget to write one or two lines as to *why* that
would benefit the mode. If I can't see the
difference/improvement, I won't change anything.

Also, my university web site is perhaps not the best
place to store it. They already closed one of my sites,
although that was a general service revocation. Anyway,
if you know of a better place to stash this material, do
tell.

-----------------------------------------------
 fpscalc in Emacs
   by Emanuel Berg
   updated: 03.30, Friday, 04/10, October 2013
-----------------------------------------------

*First* update:

This is an Emacs major mode [1] to be used with the
tool fpscalc [2]; specifically, to edit the kind of
in-data .fps files [3] crunched by fpscalc.

Have a look at the dump to get a feeling what it is
all about [4].

The mode includes:

1. A very ambitious font lock (or syntax highlight) -
   it looks like a circus at first, but once you get
   used to it, it is very useful. (I didn't use the
   font-lock faces because I want everything to be
   configurable on a per-mode/-application/whatever
   basis.)

2. The familiar (un)comment (DWIM) key: M-;

3. Indentation (very easy - I just used the C mode
   ditto - but nonetheless, it is there) [This is not
   so anymore. The C mode inheritance is dropped, and
   indentation is setup explicitly. Read on.]

4. A defun ("compute") to run fpscalc with the .fps
   program that is currently being edited in Emacs *as
   input*; then, have Emacs show the result in a new
   buffer. By default, do this with C-c C-c. This is
   more or less the same as doing it in a shell, only
   it might be a tiny bit faster not having to leave
   Emacs.

5. The mode is associated with the ".fps" extension.

*Second* update:

In the first incarnation, to get indentation, I derived
the fpscalc mode from the C mode. Because the syntaxes
are so close, I thought that would work. And it
did.... except for the M-; "!"  comment. Such comments
could be *inserted* on M-;, but not *removed*, instead,
I got another comment layer (just like the nested
quotes in messages).

Also, comments broke indentation.

So, I dropped the C mode, and the comments worked both
ways.

Last, I used some material I found on the web to get
indentation. (The code below is very close to what I
found.)

(You have to have indentation. "May I indent your
code?" is still the worst hacker insult in the book, a
book that by now has quite a heft... Seriously, it
stinks without indentation: half the time you just
match lines.)

Also, I made an example in LaTeX how to create
diagrams, that can be used in connection with fpscalc,
to illustrate task flows. Check out dumps, source,
etc. here: [5].

(I write this, as this might be Googled for fpscalc,
and lots of poor students, held at starvation point by
the pitch-dark computer industry, might benefit from
both the Emacs mode, and the diagram LaTeX skeleton
code.)

Last, writing such LaTeX code, there are lines like
this:

\gantttitlelist{,,2,,,5,,7,,9,,,12,13,,15,,17}{1}

used to produce the timeline. As you can see, to make
it work, each digit has to be preceded by as many
commas. To not have to insert those manually, I wrote
some Elisp to do the job:

(defun insert-times-helper (times last)
  (if times
      (let*((next             (car times))
            (rest             (cdr times))
            (number-of-commas (- next last) ))
        (dotimes (dummy number-of-commas) (insert ","))
        (insert (int-to-string next))
        (insert-times-helper rest next) )))
(defun insert-times (times)
  (interactive "xTimes: ")
  (insert-times-helper times 0) )

Use M-x insert-lines (2 5 7 9 12 13 15 17) RET to get
the above result.

Also, I put this in my .zshrc so I don't have to bother
with the redirection syntax of fpscalc.

# fpscalc
rt () {
    ext='.fps'
    sys=`basename $1 $ext`
    fpscalc < $sys$ext > $sys"-fallout.txt"
}

*Outro*:

Please drop me a mail at

  embe8573 A student * uu * se

if you benefited from these tools, or if you have any
comments how they can be improved.


[1 - Elisp source]
  http://user.it.uu.se/~embe8573/fps/fpscalc.el

[2 - the tool: *not* written by me; external link]
  http://www.idt.mdh.se/~ael01/fpscalc

[3 - sample input file]
  http://user.it.uu.se/~embe8573/fps/demo.fps

[4 - same dump, twice]
 http://user.it.uu.se/~embe8573/fps/fpscalc.bmp
 http://user.it.uu.se/~embe8573/fps/fpscalc.ppm

[5 - dump, source, and the PDF of a CIS (a "critical
     instant scheme")]
 http://user.it.uu.se/~embe8573/fps/cis/cis.png
 http://user.it.uu.se/~embe8573/fps/cis/task_flow_demo.pdf
 http://user.it.uu.se/~embe8573/fps/cis/task_flow_demo.tex


-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


reply via email to

[Prev in Thread] Current Thread [Next in Thread]