Affichage des articles dont le libellé est emacs. Afficher tous les articles
Affichage des articles dont le libellé est emacs. Afficher tous les articles

mercredi 10 février 2016

frictionless Java with .. clojure

Late realization: you can use clojure with Java. Not with Java. For Java. We all know clojure java interop is good, but that's not what is at play(sic). See, Java is verbose (duh), compiled (duhbl) and mute. On the other hand, clojure, being a lisp with a repl, is real-time, short and generic, and doesn't even require `print` to inspect values most of the time. So instead of writing long main println-full methods, compiling, running, parsing the output ... you just import some java classes and start poking around. Frustration: gone. Even better, clojure is human friendly, has clojure.reflect/reflect to inspect classes and/or instances; clojure.pprint/pprint for quick formatting needs. If java bytecode came with docstrings and javadoc... clojure repl would be a better IDE than Eclipse. And it's probably a few lines away to scrape some remote or local html set and get going. People probably delegate that to manual browsing or a text editor extension. Anyway, my java project makefiles [1] have now a `repl:` rule to enjoy Java without Java (sorry dude).

[1] yes, I like IDE-free projects so a makefile with a few rules. I even learned about jdb, because yeah, text mode java debugging !

dimanche 8 décembre 2013

org-mode - markdown backend -- Emacs 24.3.1

A little reminder of something I failed to do before. Org-mode has optional export backends, some are loaded by default:

(message "%S" org-export-backends)
;; "(ascii html icalendar latex)"

(add-to-list 'org-export-backends 'md)

(message "%S" org-export-backends)
;; "(md ascii html icalendar latex)"

Now in an org-mode buffer, `C-c C-e` (org-export-dispatch) will have a markdown entry accessible through `m`.

ps: done on GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 3.8.2) of 2013-08-07 on -mnt-storage-buildroots-staging-i686-eric; archlinux

jeudi 29 août 2013

org-mode 201308xx recompile needed

Had a weird issue with emacs 24 and org-mode. The vanilla package refuse to `org-clock-in` with a "can't find library: org" (I was already in org mode, but maybe some lazy loading and wrong namespace was at cause). Installed marmalade 201308.. version. Now it can't find org-with-silent... macro or other functions. Opened the source files and forced byte-compile-file. and now it work ok-ish. I can clock-in but if I delete the time-line of an open clock org-mode will lose its head and stop displaying clocks altogether. Or maybe there's a force-rewrite-clocks function but that's left for the next time to be searched.

lundi 6 mai 2013

vimgolf in emacs :: old macdonald lullaby

Bored and unwilling so doing some emacs vintage timewasting using this : http://vimgolf.com/challenges/4d29ae2107e0177c7e000036


; solution
; making a template, then iterate/expand through input once
; repeat until EOF

;; in
cow moo
horse neigh
duck quack
goose honk
hen cluck
chick peep
pig oink
sheep baa

;;out
Old MacDonald had a farm, E I E I O.
And on that farm he had a cow, E I E I O.
With a moo, moo here and a moo, moo there.
Here a moo, there a moo, everywhere a moo, moo.
Old MacDonald had a farm, E I E I O.

Old MacDonald had a farm, E I E I O.
And on that farm he had a horse, E I E I O.
With a neigh, neigh here and a neigh, neigh there.
Here a neigh, there a neigh, everywhere a neigh, neigh.
Old MacDonald had a farm, E I E I O.

Old MacDonald had a farm, E I E I O.
And on that farm he had a duck, E I E I O.
With a quack, quack here and a quack, quack there.
Here a quack, there a quack, everywhere a quack, quack.
Old MacDonald had a farm, E I E I O.

Old MacDonald had a farm, E I E I O.
And on that farm he had a goose, E I E I O.
With a honk, honk here and a honk, honk there.
Here a honk, there a honk, everywhere a honk, honk.
Old MacDonald had a farm, E I E I O.

Old MacDonald had a farm, E I E I O.
And on that farm he had a hen, E I E I O.
With a cluck, cluck here and a cluck, cluck there.
Here a cluck, there a cluck, everywhere a cluck, cluck.
Old MacDonald had a farm, E I E I O.

Old MacDonald had a farm, E I E I O.
And on that farm he had a chick, E I E I O.
With a peep, peep here and a peep, peep there.
Here a peep, there a peep, everywhere a peep, peep.
Old MacDonald had a farm, E I E I O.

Old MacDonald had a farm, E I E I O.
And on that farm he had a pig, E I E I O.
With an oink, oink here and an oink, oink there.
Here an oink, there an oink, everywhere an oink, oink.
Old MacDonald had a farm, E I E I O.

Old MacDonald had a farm, E I E I O.
And on that farm he had a sheep, E I E I O.
With a baa, baa here and a baa, baa there.
Here a baa, there a baa, everywhere a baa, baa.
Old MacDonald had a farm, E I E I O.

;; tmpl
Old MacDonald had a farm, E I E I O.
And on that farm he had a {{wat}}, E I E I O.
With a {{snd}}, {{snd}} here and a {{snd}}, {{snd}} there.
Here a {{snd}}, there a {{snd}}, everywhere a {{snd}}, {{snd}}.
Old MacDonald had a farm, E I E I O.

;; pre
;; clipboard contains input data

C-x b i n C-j ;; (buffer in)
C-y ;; input

;; preprocess input
M-< C-M-% s SPC <return> SPC <return> !
M-< C-M-% g e e s e <return> g o o s e <return> !
M-<
;; prepare template from out
C-x b o u t <enter> M-< M-h M-w C-x b t e m p C-j C-y
M-<
C-M-% c o w <enter> { { w a t } } <enter>
C-M-% m o o <enter> { { s n d } } <enter>
C-x b i n <enter>
;; main macro
<f3>
;; copy and paste template
C-x o C-x o
M-h M-w
C-x o C-y
;; put animal, sound in kill-ring
C-k
;; move 2 'Old' up
C-r O l d C-r
C-a
;; replace wat -> animal
C-s w a t <return>
M-b <delete> <delete> <delete> <delete> <delete> <backspace> <backspace> C-y
M-b M-d <backspace>
;; replace snd -> sound
C-SPC M-} C-M-% { { s n d } } <return> C-y <return> !
;; next
M-}
C-f
C-u 8 <f4>

mardi 2 avril 2013

Little elisp proto-snippet of the day : duplicate-line, select-current-line

Because `C-a C-SPC C-e M-w` just doesn't cut it, and I like playing piano, I decided to dig the web for a few helpers. I'm quite fond of the keybindings right now, let's see if they stick.

(defun duplicate-line ()
  "copy the current line underneath"
  (interactive)
  (move-beginning-of-line 1)
  (kill-line)
  (yank)
  (open-line 1)
  (next-line 1)
  (yank)
  (move-beginning-of-line 1)
  (message "TODO: restore caret position?, on original or new line?"))

(defun select-current-line ()
  "Select the current line"
  (interactive)
  ;; (end-of-line) ; move to end of line
  ;; (set-mark (line-beginning-position))

  (beginning-of-line)
  (set-mark (line-end-position))
  (message "TODO: select from begin to end or end to begin ? (caret > [begin..end]/2 => beg to end. end to beg otherwise)"))

(global-set-key (kbd "C-S-d") 'duplicate-line)
(global-set-key (kbd "C-S-l") 'select-current-line)

samedi 30 mars 2013

1998 Emacs article serie "Emacsulation" from slim[e] (common lisp) author Eric Marsden.

After Luke Gorrie's talk about SLIME origins and features, I dug for Eric Marsen (author of SLIME proto-prototype). According to http://edward.oconnor.cx/2006/01/emacsulation did an article series about Emacs around 1998. Links are dead redirection so here's the web.archive~proxy list:
  1. on jka-compr (AKA auto-compression-mode
  2. on networking, ange-ftp, w3, and crypt++
  3. an introduction to ediff
  4. on gnuserv
  5. on customizing Emacs, including material on Custom
  6. on abbrev, dabbrev, and completion
ps : Eric's webpage link section is full of things.

John Wiegley induced emacs [past]discovery of the day - edebug

EmacsConf is taking place today. John Wiegley speaks about elisp environment, including elp (profiler), edebug, and many other things. So I went to read the edebug manual a bit more (as usual I read a few pages but stopped too early).
I enjoyed the trace buffer combined with [fast]trace execution mode.

Enable the trace buffer with : `M-:` (setq edebug-trace t)

Now, let's say I have this in *scratch* (.|. being the caret)

(defun fact (n)
  (cond
   ((equal n 0) 1)
   ((* n (fact (- n 1))))))

.|.(fact 10)

`M-x` edebug-defun enters the elisp debugger

`T` will step through the s-exps in fast trace mode (automatically evaluate the next s-exp every N ms) and the *edebug-trace* buffer will trace the whole process nicely, resulting in this:

{ edebug-anon0 args: nil
:{ fact args: (10)
::{ fact args: (9)
:::{ fact args: (8)
::::{ fact args: (7)
:::::{ fact args: (6)
::::::{ fact args: (5)
:::::::{ fact args: (4)
::::::::{ fact args: (3)
:::::::::{ fact args: (2)
::::::::::{ fact args: (1)
:::::::::::{ fact args: (0)
:::::::::::} fact result: 1
::::::::::} fact result: 1
:::::::::} fact result: 2
::::::::} fact result: 6
:::::::} fact result: 24
::::::} fact result: 120
:::::} fact result: 720
::::} fact result: 5040
:::} fact result: 40320
::} fact result: 362880
:} fact result: 3628800
} edebug-anon0 result: 3628800

Kawaii, isn't it ?