Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
Ok. What you are saying makes sense. I asked some of the other guys here if they had worked on getting tags set up for our projects, but nobody had. I played with etags for a bit and was not impressed. One of the guys suggested looking into gnu global, which seems to be a lot smarter, so I'll probably do that.

Adbot
ADBOT LOVES YOU

pgroce
Oct 24, 2002
You may also find project-mode to be to your taste. I haven't used it, but it appears to be between EDE and just-a-tag-file in terms of both power and hassle.

That said, I think Fren makes good points respecting how to approach problem solving in Emacs. Take advantage of the help system. (C-h i for the info browser; C-h k (followed by typing a key or key combination) to find out what that key does; C-h f to describe functions, including telling you what keys they are currently bound to, if any; C-h v to do the same thing with variables; C-h a to do a big substring search over all the functions and variables. There's lots more, but those are the ones I use all the time.

Outside of Emacs itself, the best single resource is EmacsWiki. I prefer to search it using Google and the site: keyword.

Catalyst-proof
May 11, 2011

better waste some time with you
I actually use project-mode :3: I didn't want to suggest the use of something outside Emacs, as it's more important to grok Emacs before extending it. And EmacsWiki is a fantastic resource. Not only do I use it for all kinds of hints, snippets, and suggestions, but it also dedicates a Wiki namespace to Emacs Lisp source code, which can be installed straight within Emacs through the use of auto-install.

Beef
Jul 26, 2004
Is there a good semantic auto-complete for C/C++ modes? I guess I'm too spoiled by lisp+slime.

Ogive
Dec 22, 2002

by Lowtax

pgroce posted:

Take advantage of the help system. (C-h i for the info browser; C-h k (followed by typing a key or key combination) to find out what that key does; C-h f to describe functions, including telling you what keys they are currently bound to, if any; C-h v to do the same thing with variables; C-h a to do a big substring search over all the functions and variables. There's lots more, but those are the ones I use all the time.

C-h b describes the current mode's key bindings, which is also very useful.

pgroce
Oct 24, 2002
I was going to suggest updating the OP to point out the help commands we were just discussing more explicity, but it looks like Fren beat me to it. Thanks, and thanks for the informative OP in general!

e: ....oooor maybe it was always in there and I just missed it. Oops. Great OP anyway. :)

pgroce fucked around with this message at 15:26 on Mar 1, 2012

h_double
Jul 27, 2001
I hope this isn't too boneheaded a question but it has me scratching my head.

I'm trying to build emacs 24 from sources on a Mac (Snow Leopard) and when I run the configure script, it warns

code:
configure: error: The following required libraries were not found:
     libjpeg libgif/libungif libtiff
Maybe some development libraries/packages are missing?
If you don't want to link with them give
     --with-jpeg=no --with-gif=no --with-tiff=no
Thing is, as far as I can tell those libraries are installed (via brew) in /usr/local/lib. I've tried various permutations of './configure --libdir="/usr/local"' but it doesn't recognize them. libgif, libjpeg, and libtiff all appear to be /usr/local/lib. Thoughts?

h_double
Jul 27, 2001
Okay I gave up on completely building emacs from sources, given I found a nice build of emacs 24 as a .dmg package, and it does everything I need it to, and I've built plenty of stuff from source before.

Getting back into emacs partly because I've missed using it the past couple of years (I've mostly been using Eclipse or FlashDevelop to write code and something like Scrivener for text), partly because I'm working through the excellent Land of Lisp (which was recommended in a couple of threads here), and SLIME is very handy for lisp hacking.

I do have one question so far. I'm using the color-themes extension (and solarize-light color scheme) and the Cocoa version of emacs looks fantastic. But I like to run emacs -nw from a shell sometimes, only color-themes doesn't work right in Terminal and I don't really want it to because I like my default Terminal color scheme. Is there a way to have a bit in my .emacs that would run by the windowed version, but not when run in a terminal window? The version and emacs-version variables are the same either way.

Soricidus
Oct 21, 2010
freedom-hating statist shill

h_double posted:

Is there a way to have a bit in my .emacs that would run by the windowed version, but not when run in a terminal window? The version and emacs-version variables are the same either way.
Take a look at (display-graphic-p).

Johnny Cache Hit
Oct 17, 2011

h_double posted:

:words:
I was never able to get 24 to build from source either :( Unfortunately I'm still trying to get used to where everything ends up when I want to build something.

For posterity, I use the DMGs found here:
http://emacsformacosx.com/builds
they are nice

And as an FYI, you don't need color-themes in emacs 24; everything is built in.
http://emacs-fu.blogspot.com/2010/12/color-theming-with-emacs-24.html

ps solarize sucks zenburn ftw ;)

Catalyst-proof
May 11, 2011

better waste some time with you
If you're having trouble building Emacs 24 from source, you may want to give homebrew a try. I've never once had an issue getting it built that way. Not sure if the builds on emacsformacosx.com add any silly crap to them like Aquamacs, and they may not include Lion fullscreen.

Johnny Cache Hit
Oct 17, 2011

Fren posted:

If you're having trouble building Emacs 24 from source, you may want to give homebrew a try. I've never once had an issue getting it built that way. Not sure if the builds on emacsformacosx.com add any silly crap to them like Aquamacs, and they may not include Lion fullscreen.

AFAIK they're pretty clean builds. I guess the --HEAD flag to brew builds the latest? I'm going to try that.

Those builds don't include Lion fullscreen but let's be honest Lion fullscreen pretty much sucks anyway, so,

pgroce
Oct 24, 2002

h_double posted:

But I like to run emacs -nw from a shell sometimes, only color-themes doesn't work right in Terminal and I don't really want it to because I like my default Terminal color scheme.

In addition to what Soricidus said, also check out (info "(elisp) Window Systems"). The variable window-system will be ns if you're editing on the GUI and nil if you're on the terminal. Use term-setup-hook to run detection code and set your theme accordingly.

You could also run an Emacs server ((server-start)) when you start Emacs.app and use emacsclient to "send" files to your GUI Emacs instead of editing them in the terminal, which is what works for me.

I also use the emacsformacosx builds and have no problems.

etcetera08
Sep 11, 2008

pgroce posted:

I also use the emacsformacosx builds and have no problems.

As do I. Much better than Aquamacs, which I tried to use when this thread began.

h_double
Jul 27, 2001
Thanks for the suggestions everybody. The dmg builds of v24 from emacsformacosx are exactly what I'm using and they work great.


Kim Jong III posted:

ps solarize sucks zenburn ftw ;)

Ha, zenburn is what I use in Eclipse, but for anything other than code (text or org-mode or whatever) I prefer a lighter background for whatever reason.

h_double fucked around with this message at 19:53 on Mar 7, 2012

BusError
Jan 4, 2005

stupid babies need the most attention
Seconding the suggestion to try the homebrew version of Emacs on OS X. I just ran
code:
brew install emacs --cocoa --use-git-head --HEAD
and it worked great. Then you can symlink the app that gets installed into your /Applciations folder if you want.

Zombywuf
Mar 29, 2008

Beef posted:

Is there a good semantic auto-complete for C/C++ modes? I guess I'm too spoiled by lisp+slime.

Well, there's CEDET, but I didn't have much fun trying to get it to work. For the most part M-/ is good enough.

orphean
Apr 27, 2007

beep boop bitches
my monads are fully functional
CEDET is alot better in Emacs 24 now that's it's an official part of Emacs. It's definitely your best bet. I like to configure AutoComplete to use a semantic backend (which interfaces into CEDET).

Once that's setup and AutoComplete knows to auto-start completion on '.', '::',and '->' it's pretty much IntelliSense inside your emacs.

There's other completion modes for Emacs but I like AutoComplete the best since it doesn't use tooltips or something asinine for completion.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
I have a question about org mode.

Is this possible?

code:
* level one
  
  level one contents

 ** level two
   
    level two contents

  more level one contents.
It appears that you can't "go back" a level in the middle of a section. Is it not possible?


Edit: I guess I should expect the answer to be "why would you want to do that?"

I want to paste something huge like a callstack into my notes, and be able to collapse it. But I don't want to collapse notes after the callstack.

code:
* level one
  
  some notes

 ** a huge callstack...
 ** another huge callstack...

  more notes in level one that I don't want to be collapsed with the previous callstack.

baby puzzle fucked around with this message at 22:21 on Mar 13, 2012

Catalyst-proof
May 11, 2011

better waste some time with you
That's correct. Once you indent, you can't indicate content after it as being dedented. It's definitely more of an outline-specific format than, say, making a list of things and then digressing. For that you should just use the plain list markup.

Catalyst-proof
May 11, 2011

better waste some time with you
The answer wasn't "Why would you want to do that?" It's "a different mechanism exists for what you're trying to do." Plain lists collapse as well.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
What does that look like?

code:
* collapse test

here is some contents

- hidden stuff 1
  stuff

- hidden stuff 2
  stuff 2

i don't want this to collapse with hidden stuff 2, but it does.
It says the list is supposed to end when the indented section ends, but this example doesn't work.

Catalyst-proof
May 11, 2011

better waste some time with you
Your syntax works perfectly for me.



Check your org mode version (M-x org-version) versus the one in the screenshot.

Also, it shouldn't have much effect, but you should take care to indent things within headlines, as below:



Notice how everything lines up with the first non-whitespace character in the line "* collapse test". Org-mode comes with a bunch of useful tools to make sure stuff gets indented properly.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
What I pasted isn't indented because I'm using org-indent-mode. I turned that off and it still doesn't work.

I guess I need to update because I'm on 6.33x.

etcetera08
Sep 11, 2008

Fren posted:




How do you make it look soooo pretty? I think a decent portion of the reason I haven't learned emacs as well as I should is because I'm repelled by its aesthetics out of the box.. :downs: but yours.. yours is gorgeous.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
I don't know about Fren's setup, but I use color-theme. It has a lot of presets. I remember them all being fairly bad so I had to modify one to create my own, which hasn't gone very well so far. I also changed the default font to Consolas.

Catalyst-proof
May 11, 2011

better waste some time with you

etcetera08 posted:

How do you make it look soooo pretty? I think a decent portion of the reason I haven't learned emacs as well as I should is because I'm repelled by its aesthetics out of the box.. :downs: but yours.. yours is gorgeous.

Not sure what the font I'm using at work is, but at home I use Apple's Menlo font. The color theme above is solarized dark.

I'm working, very slowly, on a sort of Practical Emacs text that will help people use Emacs effectively out of the box. Appearance is obviously a huge part of that, and Emacs's font-face system is ridiculously sophisticated. For my gopher mode I made it a point to tweak line height, spacing, and margins for a comfortable reading experience.

etcetera08
Sep 11, 2008

Fren posted:

Not sure what the font I'm using at work is, but at home I use Apple's Menlo font. The color theme above is solarized dark.

I'm working, very slowly, on a sort of Practical Emacs text that will help people use Emacs effectively out of the box. Appearance is obviously a huge part of that, and Emacs's font-face system is ridiculously sophisticated. For my gopher mode I made it a point to tweak line height, spacing, and margins for a comfortable reading experience.



I will have to mess around a bit more when I get a chance. I think I had solarized running on Aquamacs at some point last year.

Speaking of learning Emacs, though, how do you feel about icicles? I installed it but haven't spent any time with it.

Also, is AutoInstall supposed to update my .emacs? I only see it downloading the proper .el files but not doing anything else.

EDIT: I guess I should ask this: In general, how should I be installing packages? I see there are some package managers?

etcetera08 fucked around with this message at 00:56 on Mar 14, 2012

Catalyst-proof
May 11, 2011

better waste some time with you

etcetera08 posted:

I will have to mess around a bit more when I get a chance. I think I had solarized running on Aquamacs at some point last year.

Speaking of learning Emacs, though, how do you feel about icicles? I installed it but haven't spent any time with it.

Also, is AutoInstall supposed to update my .emacs? I only see it downloading the proper .el files but not doing anything else.

I'm afraid I've never used Icicles. I would love to hear someone's opinion on it.

AutoInstall does not update your Emacs. When you require it, all it does is basically add a directory to your load-path. That directory is where all your AutoInstalled poo poo gets downloaded to. You'll need to manually add the requires you want to your .emacs.

In response to your edit: Use Emacs 24 and AutoInstall. There's more sophisticated poo poo like el-get that can go so far as to install the proper OS-level dependencies (Debian packages, what-have-you) for your Emacs setup, but I find that to be overkill. Emacs 24's packages for the heavy things, AutoInstall for the lightweight (single-file-type) things, and very occasionally you have to get your hands dirty byte-compiling things manually (auctex, w3m) but those are the rare cases.

etcetera08
Sep 11, 2008

Fren posted:

I'm afraid I've never used Icicles. I would love to hear someone's opinion on it.

AutoInstall does not update your Emacs. When you require it, all it does is basically add a directory to your load-path. That directory is where all your AutoInstalled poo poo gets downloaded to. You'll need to manually add the requires you want to your .emacs.

In response to your edit: Use Emacs 24 and AutoInstall. There's more sophisticated poo poo like el-get that can go so far as to install the proper OS-level dependencies (Debian packages, what-have-you) for your Emacs setup, but I find that to be overkill. Emacs 24's packages for the heavy things, AutoInstall for the lightweight (single-file-type) things, and very occasionally you have to get your hands dirty byte-compiling things manually (auctex, w3m) but those are the rare cases.

Oh, wow, somehow I completely missed that feature in Emacs 24. I also didn't even have 24 until now. Cool. thanks a ton. I'm sure I'll have more stupid questions in the future.

orphean
Apr 27, 2007

beep boop bitches
my monads are fully functional
Icicles is quite nice I think if a bit sprawling. Like alot of other emacs modes the rabbit hole goes pretty deep but even ignoring 98% of it's features still adds alot to the emacs experience.

It does auto-completion of course but it does it on EVERYTHING in emacs. And you do crazy stuff like 'show me a list of every function and info article containing the words buffer, frame, and point'. The once you have this list you can filter it, you can save some items for review later, etc etc.

If Icicles seems like a bit much (and honestly, it probably is a bit much :v:) maybe checkout ido-mode for a more focused autocompletion experience.

Also this probably doesn't apply to most people but running emacs on the cli (like through an SSH connnection or whatever) half-breaks icicles. It really wants to be in a windowed gui environment for all of its features to work. Just something to keep in mind.

I tend not to use icicles because I like to run a bleeding edge emacs and icicles typically gets broken often enough its not worth the hassle. This shouldn't be a problem for most people though.

Beef
Jul 26, 2004

baby puzzle posted:

What does that look like?

code:
* collapse test

here is some contents

- hidden stuff 1
  stuff

- hidden stuff 2
  stuff 2

i don't want this to collapse with hidden stuff 2, but it does.
It says the list is supposed to end when the indented section ends, but this example doesn't work.

Enter this command to make all your dreams come true:

M-x org-indent-mode

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
I had already posted that I'm using org-indent-mode.

I'm trying to update org mode. These instructions http://orgmode.org/worg/org-faq.html#installing-elpa aren't very specific. Where do I put this package.el? I put it into my .emacs.el folder and it did not work.

I also tried to install ELPA, which went fine... but apparently there are two different things called ELPA and I installed the wrong one. I guess http://elpa.gnu.org/ this is what I want, but there aren't any installation instructions there.

pgroce
Oct 24, 2002

baby puzzle posted:

What does that look like?

code:
* collapse test

here is some contents

- hidden stuff 1
  stuff

- hidden stuff 2
  stuff 2

i don't want this to collapse with hidden stuff 2, but it does.
It says the list is supposed to end when the indented section ends, but this example doesn't work.

This code has indentation problems. The dashed list items need to be indented at the same level as the c in "collapse", as does the i in "i don't...".

code:
* collapse test

  here is some contents
  
  - hidden stuff 1
    stuff
  
  - hidden stuff 2
    stuff 2

  i don't want this to collapse with hidden stuff 2, and now it doesn't.
This works in org-mode 7.8.03 in my copy of Emacs (24.0.90.1). I don't imagine that matters, though. In general, org-mode seems most comfortable when the bullets of a section are "outdented" from the content of the section.

org-mode will usually put you in the right place to continue a section if you hit return, then tab. If you hit M-return, it usually closes out the bullet you're on and starts a new one at the same level. It's not as good at dancing through indentation levels doing the "right thing" as many of the language modes, unfortunately.

etcetera08
Sep 11, 2008

Fren posted:

In response to your edit: Use Emacs 24 and AutoInstall. There's more sophisticated poo poo like el-get that can go so far as to install the proper OS-level dependencies (Debian packages, what-have-you) for your Emacs setup, but I find that to be overkill. Emacs 24's packages for the heavy things, AutoInstall for the lightweight (single-file-type) things, and very occasionally you have to get your hands dirty byte-compiling things manually (auctex, w3m) but those are the rare cases.

I've been having success playing with these. Did this and now have a buncha packages with ease. Pretty cool.

bcrules82
Mar 27, 2003
Cool, just found this thread.
Time for a contribution...

I make heavy use of Emacs' rectangular commands.
Assuming your code is lined up, automatically by either your major-mode or 'align-regexp , you'll find this useful


code:
;;;###autoload
(defun numerate-rectangle (start end beginnum &optional increment)
  "Insert sequential numbers on each line of the region-rectangle,
shifting text right.
The left edge of the rectangle specifies the column for insertion.
Called from a program, takes three args; START, END, BEGINNUM and
optional INCREMENT."
  (interactive "r\nsStart number: ")
  (setq increment (or increment 1))
  (let ((num beginnum))
    (apply-on-rectangle
     '(lambda (startcol endcol &rest args)
	(move-to-column-force startcol)
	(let ((p (point)))
	  (move-to-column-force endcol)
	  (delete-region p (point)))
	(insert num)
	(setq num (int-to-string (+ increment (string-to-int num)))))
     start end)))
I bind it to a key in my .emacs file with:
code:
(global-set-key "\C-xr#" 'numerate-rectangle)
Just mark (Ctrl-Space or mouse) your vertical rectangle, and enter the starting number.

Johnny Cache Hit
Oct 17, 2011
Anyone have experience with using emacs for Ruby development? Most of the Ruby people I know are vim users, and the EmacsWiki is kinda short on details.

Currently I have inf-ruby and rvm.el which work nicely together. I used this gist to get Pry running & turned off its pager. Right now it doesn't tab complete (throws a Ruby error) but I don't care.

Anything I'm missing? Anything I should check out? FWIW I'm doing Ruby, not RoR.

And a bonus question - something that I've wondered how to do forever. Say I have a list of numbers:

foo = test[1]
bar = test[2]
baz = test[3]

What if I want to increment each of those numbers by, say, 2? My initial thought is to create a macro to find each numeric value, but then I get stumped on how to read it in & increment. Any tips on what I should look at?

This is one of those manipulations I find myself manually whacking quite often, so I'd love to know how to do it better.

edit: ^^^ well lookit, that's pretty drat close to what I'm looking for. Going to play with that now, thanks!

Johnny Cache Hit fucked around with this message at 15:57 on Mar 20, 2012

pgroce
Oct 24, 2002
I often record one-off keyboard macros for this sort of thing. You can set a macro counter to the right initial value, then record yourself doing the replacement once, using the macro "insert counter" command instead of typing the number. (Sorry for the vagueness, I'm on my phone.)

If the job is more complicated than the above, yeah, you need a higher-voltage solution. Keyboard macros have a stupid ROI though, I bet they'll do nicely.

e: See (info "(emacs) Keyboard Macro Counter").

pgroce fucked around with this message at 17:02 on Mar 20, 2012

robotpants
Sep 10, 2005

Kim Jong III posted:

And a bonus question - something that I've wondered how to do forever. Say I have a list of numbers:

foo = test[1]
bar = test[2]
baz = test[3]

What if I want to increment each of those numbers by, say, 2? My initial thought is to create a macro to find each numeric value, but then I get stumped on how to read it in & increment. Any tips on what I should look at?

You can do neat stuff just using regexp replace; you can use arbitrary elisp in the replacement string. So to increment those numbers by two you could do
code:
 M-x query-replace-regexp <ret> [0-9]+ <ret> \,(+ 2 (string-to-number \&)) 
It's nice for that area in between keyboard macros and elisp functions.

Adbot
ADBOT LOVES YOU

pgroce
Oct 24, 2002

baby puzzle posted:

I had already posted that I'm using org-indent-mode.

I'm sorry, baby puzzle, I hadn't appreciated the significance of this when I read your message the first time.

I just stumbled on org-indent-mode and started playing with it. In passing, I noticed that the syntax I said "had indentation problems" was, in fact, perfectly fine according to the manual. So I went back and retested the sample you gave us and got essentially what Fren got -- it worked. I've upgraded my org-mode since then, so I imagine it was a bug that got fixed. (And sorry to Fren for not following his advice, too.)

Looking over this thread, I think I've been on the West Coast feed a lot. :downs: I hope I haven't been too tiresome.

Anyway, org-indent-mode. It's pretty awesome, especially in conjunction with visual-line-mode. As you can imagine from my previous post, I always found it a bit inconvenient to do longform documents with org-mode because I had to police the indentation all the time. This is much nicer than the old way I was using.

The only thing that's going to take some getting used to is storing the actual files with paragraph-long lines. I usually like to be able to open text files and Just Read Them, but the only pretty way to read these files seems to be org-indent-mode and visual-line-mode. If org will just get out my drat way when I'm writing, though, I'll get over it.

  • Locked thread