* Visitor here is a gedit user; how to interest him in Emacs?
@ 2010-08-05 6:12 David Combs
2010-08-05 7:45 ` Elena
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: David Combs @ 2010-08-05 6:12 UTC (permalink / raw)
To: help-gnu-emacs
Recently, I've been trying to interest someone in
this most wonderful program, (gnu) Emacs.
Trouble is, he's already using Gedit (google's editor);
every time I try to show him some Emacs concep, he says
that he can do that in gedit also.
This guy is really, really smart, so much though that
I myself would think that he could really benefit
himself by learning it.
Now, usually we're separated by 1,000 miles, communicating
by phone, which which it is almost impossible to demonstrate
a program: "Now hit control-X then Control-f, and then
move the cursor over to ...." -- not at all simple.
Anyway, he's here for another 30 or so hours -- so what
can I show him that might excite him into further
investigation?
Any ideas will be most welcome!
Thanks,
David
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Visitor here is a gedit user; how to interest him in Emacs?
2010-08-05 6:12 Visitor here is a gedit user; how to interest him in Emacs? David Combs
@ 2010-08-05 7:45 ` Elena
2010-08-05 7:50 ` Marc Mientki
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Elena @ 2010-08-05 7:45 UTC (permalink / raw)
To: help-gnu-emacs
Can Gedit talk to external processes, both ways? Does it have
something like Eshell? Unlike Bash, Eshell will be with you wherever
Emacs is.
Check `wdired-change-to-wdired-mode'.
Check http://www.emacswiki.org/emacs/grep-edit.el
Check the --script option, which allows you to use Emacs Lisp for
batch text processing.
Check `C-h' and show him how explorable Emacs is.
However, if that guy just needs an editor, just tell him to stick with
Gedit.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Visitor here is a gedit user; how to interest him in Emacs?
2010-08-05 6:12 Visitor here is a gedit user; how to interest him in Emacs? David Combs
2010-08-05 7:45 ` Elena
@ 2010-08-05 7:50 ` Marc Mientki
2010-08-05 17:23 ` David Combs
2010-08-05 8:06 ` Marc Mientki
` (3 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Marc Mientki @ 2010-08-05 7:50 UTC (permalink / raw)
To: help-gnu-emacs
Am 05.08.2010 08:12, schrieb David Combs:
> every time I try to show him some Emacs concep, he says
> that he can do that in gedit also.
Then let it do the following. C code is given with matrix declaration as:
int matrix[3][3];
but someone has used the 1-based indexing instead of C 0-based:
matrix[1][1] = 2;
matrix[1][2] = 6;
matrix[1][3] = 1;
matrix[2][1] = 9;
matrix[2][2] = 5;
matrix[2][2] = 12;
matrix[3][1] = 11;
matrix[3][2] = 0;
matrix[3][2] = 7;
It is simply a bug so the task is to convert this to:
matrix[0][0] = 2;
matrix[0][1] = 6;
matrix[0][2] = 1;
matrix[1][0] = 9;
matrix[1][1] = 5;
matrix[1][1] = 12;
matrix[2][0] = 11;
matrix[2][1] = 0;
matrix[2][1] = 7;
In general, there may be hundreds or thousands of references to matrix,
so the solution must be intelligent enough that such things are not
taken into account:
Amatrix[1][2]
InMatrix[2][1]
_matrix[2][2]
matrix[2][1][2]
a_matrix[3][1]
.matrix[3][2]
But this very well:
+matrix[1][3]
- matrix[3][2]
Can Gedit process such thing?
regards
Marc
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Visitor here is a gedit user; how to interest him in Emacs?
2010-08-05 6:12 Visitor here is a gedit user; how to interest him in Emacs? David Combs
2010-08-05 7:45 ` Elena
2010-08-05 7:50 ` Marc Mientki
@ 2010-08-05 8:06 ` Marc Mientki
2010-08-05 12:57 ` Pascal J. Bourguignon
2010-08-05 8:25 ` Elena
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Marc Mientki @ 2010-08-05 8:06 UTC (permalink / raw)
To: help-gnu-emacs
Am 05.08.2010 08:12, schrieb David Combs:
> every time I try to show him some Emacs concep, he says
> that he can do that in gedit also.
Another example. Let him convert that
value_at_1_4 = 10;
value_at_2_2 = 11;
value_at_5_1 = 300;
to this:
value[3][0] = 10;
value[1][1] = 11;
value[0][4] = 300;
So he should extract two last number parts from variable name, remove
'_at_' from name, use both index for c-array-indexing but in reverse
order and 0-based (original was 1-based). Of course everything in one
pass in full automatic :-)
regards
Marc
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Visitor here is a gedit user; how to interest him in Emacs?
2010-08-05 6:12 Visitor here is a gedit user; how to interest him in Emacs? David Combs
` (2 preceding siblings ...)
2010-08-05 8:06 ` Marc Mientki
@ 2010-08-05 8:25 ` Elena
2010-08-05 14:55 ` despen
2010-08-06 5:49 ` TheFlyingDutchman
5 siblings, 0 replies; 11+ messages in thread
From: Elena @ 2010-08-05 8:25 UTC (permalink / raw)
To: help-gnu-emacs
Check orgtbl-mode, too. I think there is a screencast here (I can't
watch Youtube videos right now):
http://www.google.it/url?url=http://www.youtube.com/watch%3Fv%3DEQAd41VAXWo&rct=j&sa=X&ei=0HNaTIy2I5egsQbpoYl5&ved=0CBkQuAIwAA&q=emacs+power+can+your+editor+do+this&usg=AFQjCNH2JLR5CFXOs_OXnJQUvn5sI3UzMQ&cad=rja
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Visitor here is a gedit user; how to interest him in Emacs?
2010-08-05 8:06 ` Marc Mientki
@ 2010-08-05 12:57 ` Pascal J. Bourguignon
2010-08-05 14:46 ` Marc Mientki
0 siblings, 1 reply; 11+ messages in thread
From: Pascal J. Bourguignon @ 2010-08-05 12:57 UTC (permalink / raw)
To: help-gnu-emacs
Marc Mientki <mientki@nonet.com> writes:
> Am 05.08.2010 08:12, schrieb David Combs:
>
>> every time I try to show him some Emacs concep, he says
>> that he can do that in gedit also.
>
> Another example. Let him convert that
>
> value_at_1_4 = 10;
> value_at_2_2 = 11;
> value_at_5_1 = 300;
>
> to this:
>
> value[3][0] = 10;
> value[1][1] = 11;
> value[0][4] = 300;
> So he should extract two last number parts from variable name, remove
> _at_' from name, use both index for c-array-indexing but in reverse
> order and 0-based (original was 1-based). Of course everything in one
> pass in full automatic :-)
Even better:
/*
matrix is:
| 2 9 11 |
| 6 5 0 |
| 1 12 7 |
*/
and have it transform this comment into the matrix intialization code:
matrix[1][1]=2;
matrix[1][2]=6;
matrix[1][3]=1;
matrix[2][1]=9;
matrix[2][2]=5;
matrix[2][3]=12;
matrix[3][1]=11;
matrix[3][2]=0;
matrix[3][3]=7;
(defun matrix-to-c (start end)
(interactive "r")
(goto-char start)
(when (re-search-forward "\\([_A-Za-z][_A-Za-z0-9]*\\) *is *:" end t)
(let ((name (match-string 1))
(data '()))
(while (re-search-forward "|\\(.*\\)|" end t)
(push (first (read-from-string (concat "(" (match-string 1) ")"))) data))
(setf data (reverse data))
(search-forward "*/")
(goto-char (match-end 0))
(insert "\n")
(loop
for j from 1 to (length data)
do (loop
for i from 1 to (length (first data))
do (insert (format "%s[%s][%s]=%s;\n" name j i (elt (elt data (1- i)) (1- j)))))))))
--
__Pascal Bourguignon__ http://www.informatimago.com/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Visitor here is a gedit user; how to interest him in Emacs?
2010-08-05 12:57 ` Pascal J. Bourguignon
@ 2010-08-05 14:46 ` Marc Mientki
0 siblings, 0 replies; 11+ messages in thread
From: Marc Mientki @ 2010-08-05 14:46 UTC (permalink / raw)
To: help-gnu-emacs
Am 05.08.2010 14:57, schrieb Pascal J. Bourguignon:
> Marc Mientki<mientki@nonet.com> writes:
>
>> Am 05.08.2010 08:12, schrieb David Combs:
>>
>>> every time I try to show him some Emacs concep, he says
>>> that he can do that in gedit also.
>>
>> Another example. Let him convert that
>>
>> value_at_1_4 = 10;
>> value_at_2_2 = 11;
>> value_at_5_1 = 300;
>>
>> to this:
>>
>> value[3][0] = 10;
>> value[1][1] = 11;
>> value[0][4] = 300;
>
>> So he should extract two last number parts from variable name, remove
>> _at_' from name, use both index for c-array-indexing but in reverse
>> order and 0-based (original was 1-based). Of course everything in one
>> pass in full automatic :-)
>
> Even better:
>
> /*
>
> matrix is:
> | 2 9 11 |
> | 6 5 0 |
> | 1 12 7 |
>
> */
>
> and have it transform this comment into the matrix intialization code:
>
> matrix[1][1]=2;
> matrix[1][2]=6;
> matrix[1][3]=1;
> matrix[2][1]=9;
> matrix[2][2]=5;
> matrix[2][3]=12;
> matrix[3][1]=11;
> matrix[3][2]=0;
> matrix[3][3]=7;
>
>
>
>
>
>
> (defun matrix-to-c (start end)
> (interactive "r")
> (goto-char start)
> (when (re-search-forward "\\([_A-Za-z][_A-Za-z0-9]*\\) *is *:" end t)
> (let ((name (match-string 1))
> (data '()))
> (while (re-search-forward "|\\(.*\\)|" end t)
> (push (first (read-from-string (concat "(" (match-string 1) ")"))) data))
> (setf data (reverse data))
> (search-forward "*/")
> (goto-char (match-end 0))
> (insert "\n")
> (loop
> for j from 1 to (length data)
> do (loop
> for i from 1 to (length (first data))
> do (insert (format "%s[%s][%s]=%s;\n" name j i (elt (elt data (1- i)) (1- j)))))))))
>
Very fine example!
Normaly I prefere to write small piece elisp code to solve such task,
too. But sometimes I find a puzzle with macros very funny, especialy in
non trivial cases like this one. So I wrote matrix-to-c as macro. With
some limitations it works fine.
First limitation: I expect matrix form without '|':
2 9 11
6 5 0
1 12 7
Second: I use genial macro-math.el from Nikolaj Schumacher with
following key bindings:
(global-set-key "\C-x~" 'macro-math-eval-and-round-region)
(global-set-key "\C-x=" 'macro-math-eval-region)
This is my solution:
M-C-s ;; isearch-forward-regexp
[0-9] ;; self-insert-command * 5
RET ;; newline-and-indent
C-a ;; move-beginning-of-line
TAB ;; c-indent-line-or-region
C-M-SPC ;; mark-sexp
C-x r s ;; copy-to-register
1 ;; self-insert-command
C-w ;; kill-region
matrix[ ;; self-insert-command * 7
C-SPC ;; set-mark-command
( ;; c-electric-paren
C-x C-k <tab>
-1 ;; self-insert-command * 2
) ;; c-electric-paren
/ ;; c-electric-slash
3 ;; self-insert-command
C-u 0 C-x ~ ;; macro-math-eval-and-round-region
][ ;; self-insert-command * 2
C-SPC ;; set-mark-command
C-u C-x C-k <tab>
%3 ;; self-insert-command * 2
C-x = ;; macro-math-eval-region
] ;; self-insert-command
SPC ;; self-insert-command
= ;; self-insert-command
SPC ;; self-insert-command
C-u C-x r i ;; insert-register
1 ;; self-insert-command
; ;; c-electric-semi&comma
RET ;; newline-and-indent
Or ready to use:
(fset 'matrix-to-c
[?\C-\M-s ?\[ ?0 ?- ?9 ?\] ?\C-m ?\C-a ?\C-i ?\C-\M- ?\C-x ?r ?s ?1
?\C-w ?m ?a ?t ?r ?i ?x ?\[ ?\C- ?\( ?\C-x ?\C-k tab ?- ?1 ?\) ?/ ?3
?\C-u ?0 ?\C-x ?~ ?\] ?\[ ?\C- ?\C-u ?\C-x ?\C-k tab ?% ?3 ?\C-x ?= ?\]
? ?= ? ?\C-u ?\C-x ?r ?i ?1 ?\; ?\C-m])
So now one can paste matrix form into C code:
2 9 11
6 5 0
1 12 7
init emacs macro counter to 0 (C-x C-k C-c 0 RET) and then call 9 times
matrix-to-c:
C-u 9 M-x matrix-to-c
and we get:
matrix[0][0] = 2;
matrix[0][1] = 9;
matrix[0][2] = 11;
matrix[1][0] = 6;
matrix[1][1] = 5;
matrix[1][2] = 0;
matrix[2][0] = 1;
matrix[2][1] = 12;
matrix[2][2] = 7;
(I used first index as row, second as col, 0-based).
I love Emacs! :-)
regards
Marc
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Visitor here is a gedit user; how to interest him in Emacs?
2010-08-05 6:12 Visitor here is a gedit user; how to interest him in Emacs? David Combs
` (3 preceding siblings ...)
2010-08-05 8:25 ` Elena
@ 2010-08-05 14:55 ` despen
2010-08-06 5:49 ` TheFlyingDutchman
5 siblings, 0 replies; 11+ messages in thread
From: despen @ 2010-08-05 14:55 UTC (permalink / raw)
To: help-gnu-emacs
dkcombs@panix.com (David Combs) writes:
> Recently, I've been trying to interest someone in
> this most wonderful program, (gnu) Emacs.
>
> Trouble is, he's already using Gedit (google's editor);
Gnome Edit. It's only hosted at google code.
> every time I try to show him some Emacs concep, he says
> that he can do that in gedit also.
Leave him alone. You'll only annoy him.
Gedit focuses on simplicity. Some users like that over
being able to do almost anything.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Visitor here is a gedit user; how to interest him in Emacs?
2010-08-05 7:50 ` Marc Mientki
@ 2010-08-05 17:23 ` David Combs
2010-08-05 17:46 ` David Kastrup
0 siblings, 1 reply; 11+ messages in thread
From: David Combs @ 2010-08-05 17:23 UTC (permalink / raw)
To: help-gnu-emacs
In article <i3dqfp$tmq$1@news.onet.pl>,
Marc Mientki <mientki@nonet.com> wrote:
>Am 05.08.2010 08:12, schrieb David Combs:
>
>> every time I try to show him some Emacs concep, he says
>> that he can do that in gedit also.
>
>Then let it do the following. C code is given with matrix declaration as:
> int matrix[3][3];
>
>but someone has used the 1-based indexing instead of C 0-based:
>
> matrix[1][1] = 2;
> matrix[1][2] = 6;
> matrix[1][3] = 1;
> matrix[2][1] = 9;
> matrix[2][2] = 5;
> matrix[2][2] = 12;
> matrix[3][1] = 11;
> matrix[3][2] = 0;
...
...
...
OK -- now, to show him the POWER of emacs, PLEASE, PLEASE
show the solution to the problem, ie via keyboard macros,
functions, commands, etc.
And I bet we'll ALL learn some nice technique from
your implementation.
THANKS!
David
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Visitor here is a gedit user; how to interest him in Emacs?
2010-08-05 17:23 ` David Combs
@ 2010-08-05 17:46 ` David Kastrup
0 siblings, 0 replies; 11+ messages in thread
From: David Kastrup @ 2010-08-05 17:46 UTC (permalink / raw)
To: help-gnu-emacs
dkcombs@panix.com (David Combs) writes:
> In article <i3dqfp$tmq$1@news.onet.pl>,
> Marc Mientki <mientki@nonet.com> wrote:
>>Am 05.08.2010 08:12, schrieb David Combs:
>>
>>> every time I try to show him some Emacs concep, he says
>>> that he can do that in gedit also.
>>
>>Then let it do the following. C code is given with matrix declaration as:
>> int matrix[3][3];
>>
>>but someone has used the 1-based indexing instead of C 0-based:
>>
>> matrix[1][1] = 2;
>> matrix[1][2] = 6;
>> matrix[1][3] = 1;
>> matrix[2][1] = 9;
>> matrix[2][2] = 5;
>> matrix[2][2] = 12;
>> matrix[3][1] = 11;
>> matrix[3][2] = 0;
> ...
> ...
>
> OK -- now, to show him the POWER of emacs, PLEASE, PLEASE
> show the solution to the problem, ie via keyboard macros,
> functions, commands, etc.
Hm? That's not particularly hard.
C-M-% \<matrix\[\([0-9]+\)]\[\([0-9]+\)] RET
matrix[\,(1- \#1)][\,(1- \#2)] RET
> And I bet we'll ALL learn some nice technique from
> your implementation.
I doubt it. That's more basic than the more complex examples in the
Emacs manual for regexp replacement.
--
David Kastrup
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Visitor here is a gedit user; how to interest him in Emacs?
2010-08-05 6:12 Visitor here is a gedit user; how to interest him in Emacs? David Combs
` (4 preceding siblings ...)
2010-08-05 14:55 ` despen
@ 2010-08-06 5:49 ` TheFlyingDutchman
5 siblings, 0 replies; 11+ messages in thread
From: TheFlyingDutchman @ 2010-08-06 5:49 UTC (permalink / raw)
To: help-gnu-emacs
> Recently, I've been trying to interest someone in
> this most wonderful program, (gnu) Emacs.
>
> Trouble is, he's already using Gedit (google's editor);
What is he using Gedit for?
Don't know if he is a C/C++ programmer, but it is nice to be able to
compile - get the compiler output and then jump to the error in the
source code. From looking at Gedit it doesn't look that it can do that
IDE-type function.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-08-06 5:49 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-05 6:12 Visitor here is a gedit user; how to interest him in Emacs? David Combs
2010-08-05 7:45 ` Elena
2010-08-05 7:50 ` Marc Mientki
2010-08-05 17:23 ` David Combs
2010-08-05 17:46 ` David Kastrup
2010-08-05 8:06 ` Marc Mientki
2010-08-05 12:57 ` Pascal J. Bourguignon
2010-08-05 14:46 ` Marc Mientki
2010-08-05 8:25 ` Elena
2010-08-05 14:55 ` despen
2010-08-06 5:49 ` TheFlyingDutchman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).