Author Topic: Emacs - how and where?  (Read 8162 times)

0 Members and 1 Guest are viewing this topic.

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Emacs - how and where?
« on: November 26, 2018, 10:19:26 pm »
I have noted that "Emacs" is usually quoted a lot of times in this forum. On topics about C, IDE, VHDL, ... there are a lot of matching quotes but without convincing details.

Try to convince me that it's a really good thing  :D
 

Offline blacksheeplogic

  • Frequent Contributor
  • **
  • Posts: 532
  • Country: nz
Re: Emacs - how and where?
« Reply #1 on: November 26, 2018, 10:41:37 pm »
Try to convince me that it's a really good thing  :D

Why?   Use whatever works best for your workflow. I use VI/VIM, Quartus, or  MSVS depending on what I'm doing.
 

Offline NegativeONE

  • Contributor
  • Posts: 20
  • Country: pl
    • NegativeONE - personal page
Re: Emacs - how and where?
« Reply #2 on: November 26, 2018, 11:07:25 pm »
Try to convince me that it's a really good thing  :D

You will be able to join The Church of Emacs and became a follower of Saint IGNUcius :)

ONE never notices what has been done;
ONE can only see what remains to be done;

http://www.negativeone.pl
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11248
  • Country: us
    • Personal site
Re: Emacs - how and where?
« Reply #3 on: November 26, 2018, 11:42:15 pm »
It is not. Most of the people using it got used to it when there were no decent alternatives.
Alex
 

Offline jmelson

  • Super Contributor
  • ***
  • Posts: 2765
  • Country: us
Re: Emacs - how and where?
« Reply #4 on: November 26, 2018, 11:50:21 pm »
I have noted that "Emacs" is usually quoted a lot of times in this forum. On topics about C, IDE, VHDL, ... there are a lot of matching quotes but without convincing details.

Try to convince me that it's a really good thing  :D
Um, well, emacs does have language-specific features, but I really don't care for them.  I've been using emacs for about 20 years, but I only use about 1% of the available features.  It does have some good pattern matching and bulk find and replace operations that come in handy pretty often.

Jon
 

Offline boffin

  • Supporter
  • ****
  • Posts: 1027
  • Country: ca
Re: Emacs - how and where?
« Reply #5 on: November 27, 2018, 12:14:56 am »
joe:
Joe's Own Editor. Much overlooked, but powerful and small; been my go to for many years.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4032
  • Country: nz
Re: Emacs - how and where?
« Reply #6 on: November 27, 2018, 03:24:53 am »
It is not. Most of the people using it got used to it when there were no decent alternatives.

I can't address "most". That would imply people who got used to emacs before, say, 1985 -- and even that will surely draw protests that vi was available before that and is a decent alternative. As was EDT/TPU.

In my own case, I didn't switch to emacs until 1997, at which time I was already experienced with (at least) the following decent alternatives:

- Brief
- Visual Studio
- MPW
- BBEdit
- CodeWarrior
- THINK C
- THINK Pascal

However, no matter how good any of those were in their home territory (e.g. DOS, Windows, Mac), they were restricted to one OS, and possibly one language.

Emacs might have some slight weakness compared to some of those in some areas, but it has the HUGE HUGE benefit that I was able to adopt it immediately and share my .emacs customisations on all of Windows, MacOS, Linux, Solaris, HP/UX and (the first places I used emacs) Tandem NonStop OS and Stratus VOS fault-tolerant computers.
 

Offline blacksheeplogic

  • Frequent Contributor
  • **
  • Posts: 532
  • Country: nz
Re: Emacs - how and where?
« Reply #7 on: November 27, 2018, 03:47:30 am »
However, no matter how good any of those were in their home territory (e.g. DOS, Windows, Mac), they were restricted to one OS, and possibly one language.

When I started out we just had "ed" on serial terminals. Pretty sure there's a variant out there for any OS, I worked on COBOL using an "ed" variant on several propitiatory systems. Still don't see compatibility as a compelling reason to go back to it.
 

Offline agehall

  • Frequent Contributor
  • **
  • Posts: 383
  • Country: se
Re: Emacs - how and where?
« Reply #8 on: November 27, 2018, 05:15:38 am »
I would argue that Emacs is one of the most powerful editors out there but unfortunately it is outdated in many ways.

There are many other editors which has comparable potential, but Emacs has a looooong history and it caught on so there are extensions for more or less everything that works really well for it. Most other editors does not have the same ecosystem.

I'm still use Emacs for a lot of things since it was my primary IDE for over 20 years but today there are many alternatives that works just as well or better.

Emacs still has a few edges here and there imho, but they are getting fewer and fewer. I would no longer recommend anyone to use Emacs as their primary editor, but I would still recommend that all serious developers on non-windows platforms learn the basics of both Emacs and Vi - you never know when you'll need it! (Like, for example, when you need to exit one of them!)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Emacs - how and where?
« Reply #9 on: November 27, 2018, 05:43:38 am »
Quote
Most of the people using it got used to it when there were no decent alternatives.
Quote
[especially when in came to multi-OS editors.]
That would be me.  In the early days, there were EMACS-like editors for TOPS10 (FINE), ITS, TOPS20, and TENEX ("real, TECO-based EMACS!"), cp/m (MINCE) and unix/vms (elle, via Eunice) - everything I used or was likely to use.  When unix became available to mortals, there were additional OSSW and commercial versions.
Prior to EMACS, I used actual DEC TECO (which is awful, but which I still occasionally miss) and SPF (IBM3270 full-screen editor.  Really nice, actually, especially for the time.)
Between EMACS and assorted IDE editors that I'm more-or-less compelled to use if I want to used the vendors' IDEs (most of which are pretty sucky) (and, you know, actual document-editing SW for actual documents), I haven't been very motivated to look for anything else.  Yeah, it's pretty bloated, and includes thousands of features I have no interest in, and its window management (in particular) dates to the pure-text days and is rarely "native-feeling" on any OS.  But it would take something that was obviously substantially better to get me to switch, and that seems ... unlikely - there just isn't that much I want a code editor to do.  (to be fair, I may be a bit of a luddite; it took me ages to turn on colorization!)  (ok, when programming in a less familiar environment, the context-sensitive help/autocomplete in some IDEs is pretty nice...)

One of the things I like about emacs at the moment, is that keyboard macros can be rendered as text, edited, and included in the source code.  So if I use some macro to convert an intel .hex file to a C string, I can just plunk that macro down in a comment in case I need to use it again, sometime.  (like: https://github.com/WestfW/OptiLoader/blob/master/optiLoader.ino#L682)

 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4032
  • Country: nz
Re: Emacs - how and where?
« Reply #10 on: November 27, 2018, 06:08:50 am »
You can also do that as

(setq last-kbd-macro
   [?  ?  ?  ?  ?\" ?\C-e ?\" ?\\ ?n ?\C-a ?\C-n])

Type C-x C-e after the closing paren to evaluate it, and then it's just the same as if it was freshly define i.e. type C-X e to apply it.

Or give it a real function name, or bind it to a key
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: Emacs - how and where?
« Reply #11 on: November 27, 2018, 07:57:30 am »
Let's see if Eliza can convince you...though I doubt it  :-//
M-x doctor
Code: [Select]
I am the psychotherapist.  Please, describe your problems.  Each time
you are finished talking, type RET twice.

Is emacs a good thing?

What do you think?

Well, I personally like it...

Why do you say you personally like it?

It's powerful enough, not really bloated for current computers and it's not vi

You have your mind on computers, it seems.

Yes, since I was 13

What happened when you were 13?

Let's talk about Emacs

Emacs?  Hah!  I would appreciate it if you would continue.

I was expecting some insight from you

Is it because of your plans that you say you were expecting some
insight from me?

No, just someone asked on a forum I contribute to

Maybe your life has something to do with this.

You might be right

Is it because of the people you hang around with that you say I might
be right?

They are mostly nice persons

Is it because of any hobbies you have that you say they are mostly
nice persons?

You nailed it
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline bson

  • Supporter
  • ****
  • Posts: 2270
  • Country: us
Re: Emacs - how and where?
« Reply #12 on: November 27, 2018, 08:16:56 am »
I typically reach for emacs whenever I need to do substantial original work as opposed to just fix bugs or make minor rearrangements.  Here's a video where I grab a register map from a datasheet and turn it into an enum:

1. Copy and paste
2. Remove "RESERVED" entries
3. Format one entry, recording it as a keyboard macro, leaving the point at the start of the next entry
4. Repeat the keyboard macro for the rest
5. Various cleanups (e.g. "0x00h" -> "0x00")
6. Comment
7. Done

https://youtu.be/jIYTXWF8EO8

I use similar techniques a lot when I need to generate tables or turn tables in e.g. datasheets or word documents into code.  Emacs being legacy enough to strip all text formatting and turn it into ASCII is actually a benefit here.

I also prefer to use emacs whenever I use gdb to debug - which is when doing more complex work that requires evaluating expressions that involve type casting or calling functions (gdb is one of the few debuggers that will do this), useful if you have more elaborate debug support code like dumping complex data structure state, like buffer pools.  For example, given const uint8_t* buffer pointing to an ethernet frame, "print/x *(tcphdr*)((buffer+14+(iph*)(buffer+14))->ip_hlen*4+buffer+14))".  Since it's a general expression the same can be used e.g. to conditionally stop on a watchpoint or breakpoint, for example if you see a TCP SYN.  It just makes for really quick and effective tracking down of complex bugs.  Many of the IDE based tools simply can't do many of the same things (although MSVS is programmable and also quite capable).
 
« Last Edit: November 27, 2018, 08:20:22 am by bson »
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Emacs - how and where?
« Reply #13 on: November 27, 2018, 08:17:32 am »
Let's see if Eliza can convince you

LOL, is it included in Emacs?  :-DD
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11248
  • Country: us
    • Personal site
Re: Emacs - how and where?
« Reply #14 on: November 27, 2018, 08:18:47 am »
LOL, is it included in Emacs?  :-DD
Yes, but the novelty wears off quite fast. And then you think - does this belong in a text editor?
Alex
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Emacs - how and where?
« Reply #15 on: November 27, 2018, 08:25:59 am »
Talking about VHDL, the big difference in approach between Sigasi and Emacs VHDL mode is this: Emacs uses regular expressions to make guesses about your code, while Sigasi has a real parser that understands your VHDL code.

As a result, you get:
  • Error messages while you type thanks to the ultra fast built-in compiler that gives you error messages while you are typing, much like a spell checker in a word processor.
  • Navigation Every declaration is just one button away. Do you want to go to the declaration of a certain constant, signal or entity? Just press F3! (tags are sometimes broken on Emacs)
  • Mouse-over hovers Learn about any identifier just by hovering your mouse over the name.
  • Compile your files Export the correct build order and library mapping of your VHDL files as an automatically updated csv file.

This, plus code analysis.


During the next weekend, I am willing to try Emacs Vhdl-mode (and Sigasi Emacs Vhdl-mode emulation) more deeply, anyway.
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Emacs - how and where?
« Reply #16 on: November 27, 2018, 08:30:16 am »
It does have some good pattern matching and bulk find and replace operations that come in handy pretty often.

This may be a reason for using it. Or for copying this feature into a dedicated tool.

I find "sed" useful when I have to replace a lot of sparse patterns in large projects (hundred files), and I usually use "find" combined with "grep" and "sed" in a bash script.
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: Emacs - how and where?
« Reply #17 on: November 27, 2018, 08:33:08 am »
I typically reach for emacs whenever I need to do substantial original work as opposed to just fix bugs or make minor rearrangements.  Here's a video where I grab a register map from a datasheet and turn it into an enum:

1. Copy and paste
2. Remove "RESERVED" entries
3. Format one entry, recording it as a keyboard macro, leaving the point at the start of the next entry
4. Repeat the keyboard macro for the rest
...
That's also what I (and I imagine most Emacs users past basics) used to do.
But what I do now with Code (and a bit less with VS) is using multiple cursors, the same applies to many modern editors such as Sublime:
1. C&P
2. Make non-repeating edits
3. Match one entry (either separator, regex, whatever)
4. Extend the selection to all matches (or just alt-click them if they are few)
5. Do the common edits
6. Hit Esc to return to a single cursor.

But this would more in topic for the IDE thread...

LOL, is it included in Emacs?  :-DD
Yes, but the novelty wears off quite fast. And then you think - does this belong in a text editor?
Well, Emacs icon was not chosen at random...
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Emacs - how and where?
« Reply #18 on: November 27, 2018, 08:49:32 am »
LOL, is it included in Emacs?  :-DD
Yes, but the novelty wears off quite fast. And then you think - does this belong in a text editor?

Mine doesn't have it. It was compiled in 2009 with just the essential flags (Gentoo L1-profile).
I see I can also rebuild emacs with X11 support. Umm.

I will compile a modern version of Emacs, but first I have to update the remote server ...

Code: [Select]
2018-11-27--00-03-22---2018-11-27--00-05-40 - [ app-editors/emacs ] - failure - root@dev2.25.1/5.4.0
net-libs/webkit-gtk-2.22.2: GCC 6.0.0 is required to build WebKitGTK+, use a newer GCC version
2018-11-27--00-03-22---2018-11-27--00-05-41 - [ =sys-devel/gcc-6.4.0-r1 ] - failure -
use a newer glibc version
2018-11-27--00-27-14---2018-11-27--00-27-35 - [ sys-libs/glibc ] - failure - root@dev2.25.1/5.4.0
 * Checking gcc for __thread support ...     
 * Checking running kernel version (2.6.39-flash-eating-bats-II-gentoo-ia32-t23 >= 3.2.0) ...   
You need a kernel of at least 3.2.0!

glibc, gcc, and the kernel need to be updated  :-DD

No problem, I will! That machine hasn't been updated recently.

Anyway, Emacs has too many dependencies, anyway. There is too much stuff there.

Code: [Select]
app-editors/emacs
version=26.1-r3
needs=C,C++,lisp
USE="X acl gif gpm gtk imagemagick inotify jpeg motif png source ssl svg threads tiff toolkit-scroll-bars wide-int xft xpm xwidgets zlib -Xaw3d -alsa (-aqua) -athena (-cairo) -dbus -dynamic-loading -games -gconf -gfile -gsettings -gtk2 -gzip-el -kerberos -lcms -libxml2 -livecd -m17n-lib -mailutils (-selinux) -sound -systemd"

Among flags .... imagemagick inotify jpeg motif png livecd ssl alsa games kerberos sound ?!?!? WTF?!?

It's not an "editor", it's ... what is it? an OS?  :-//
« Last Edit: November 27, 2018, 08:52:43 am by legacy »
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Emacs - how and where?
« Reply #19 on: November 27, 2018, 09:05:07 am »
One thing I still have to understand ... is why people still want modal text editor features through emulation

See Sigasi? There is Emacs emulation mode
See Kate? There is Vi emulation mode

Both these two features are modal-text-editor emulations  :-//
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: Emacs - how and where?
« Reply #20 on: November 27, 2018, 01:06:08 pm »
See Sigasi? There is Emacs emulation mode
[...]
Both these two features are modal-text-editor emulations  :-//
But have you ever used Emacs?
I don't think it can be called "modal" for any reasonable definition of the term!

It has got primary "modes", as in C-mode, fortran-mode, picture-mode (unconstrained cursor movement etc.) or hexl-mode, and secondary ones that refine part of the behaviour, e.g. font-lock-mode (AKA syntax highlighting) , or transient-mark-mode (selection behaviour).

But, in general, you move where you want to edit and edit, editing commands are attached to non-self-inserting keys (or key combinations).
No switching to a different "mode" to save or quit. Just like notepad.exe, with a bit more power...
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Emacs - how and where?
« Reply #21 on: November 27, 2018, 02:19:18 pm »
But have you ever used Emacs?

To enable/disable the "Emacs VHDL mode" emulation you have to press a key. By looking at what he types, I have noted that my colleague, during a work, enables and disables the emulation mode several times.

Ok, it's not the same, but it looks very similar to what you have to do with VI.
 

Offline Bassman59

  • Super Contributor
  • ***
  • Posts: 2501
  • Country: us
  • Yes, I do this for a living
Re: Emacs - how and where?
« Reply #22 on: November 27, 2018, 05:23:29 pm »
But have you ever used Emacs?

To enable/disable the "Emacs VHDL mode" emulation you have to press a key. By looking at what he types, I have noted that my colleague, during a work, enables and disables the emulation mode several times.

Ok, it's not the same, but it looks very similar to what you have to do with VI.

Emacs automatically goes into vhdl mode if you load in VHDL source code, as indicated by the file extension. There is no need to go into and out of the mode. And the mode is active only for VHDL source buffers, so if you switch to a makefile, emacs goes into its makefile mode. If you switch to a plain text file, it switches to a plain text editing mode.

The real power of emacs' vhdl-mode is not that it doesn't analyze the code as you type (like Sigasi). Rather, it's the templating.

Again, type the two letters pr then hit the tab key, and it'll create a process skeleton for you. If you've specified them, it'll even put in the clock and reset signals. This saves a whole lot of typing, and I haven't seen another editor that does this. There are similar autocomplete/templates for pretty much every VHDL construct you can think of. Declaring signals? Type si then hit tab, and it'll autocomplete the word "signal," then when you hit the space bar it asks for the signal name, enter it, space again, then it asks for the signal type (which can autocomplete itself), then it'll ask for an initializer value (if you have none, hit enter, then it'll ask for a comment. It's truly great.

Something else that makes the emacs-mode invaluable is the autocomplete. Start typing something, like a signal name, and hit tab, and it'll autocomplete. Repeatedly hit tab and it'll cycle through everything that might fit.

Wanna create a test bench skeleton? Put your cursor in an entity's port list, and from the menu select VHDL -> Port -> Copy (or use the keyboard shortcuts Ctrl-C Ctrl-P Ctrl-W). Then visit a new file (Ctrl-X Ctrl-F, then give it a name) and in that new file, choose from the menu VHDL -> Port -> Paste As Testbench (or Ctrl-c Ctrl-c Ctrl-t). Bam -- it creates a testbench skeleton, with signal declarations, an instance of the DUT and a clock-generator process.

And so on.

As for obtaining emacs, I don't build from source. For Windows I just grab it from the Gnu website. For the Mac I get it from the Emacs for Mac OS X website.
 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
Re: Emacs - how and where?
« Reply #23 on: November 27, 2018, 06:28:15 pm »
I'm a long-time Emacs user (and in college was a hired typist for rms for a few sessions until I couldn't take it anymore...)

For me, Emacs features that I have a hard-time finding replacements for:
1. Shell mode. Run processes in buffers, having a quick way to save the output for later remembering, documentation, or whatever.
2. Keyboard macros. As described above. More powerful than they first appear.
3. Mark-ring (multiple clipboards, done right)
4. Tramp - edit files on remote systems as if they were local (sort of).
5. Scripting is first-class. You can write code to edit files.
6. Incremental search
7. Template.el for new files-programmable
8. Dabbrev (auto-completion)
9. Babel-mode.
 

Offline Bassman59

  • Super Contributor
  • ***
  • Posts: 2501
  • Country: us
  • Yes, I do this for a living
Re: Emacs - how and where?
« Reply #24 on: November 27, 2018, 07:16:52 pm »
LOL, is it included in Emacs?  :-DD
Yes, but the novelty wears off quite fast. And then you think - does this belong in a text editor?

Does Tetris belong in a text editor?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf