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
Zombywuf
Mar 29, 2008

comedyblissoption posted:

M-x visual-lines-mode

M-x toggle-truncate-lines if you want lines to not wrap

Real men M-q :colbert:

Your Computer posted:

What makes these text editors better than an IDE? I guess I'm very "new-school" with how I program, but I wouldn't want to switch over to something that does not have autocomplete, method-lookups, auto-import and other niceties such as browsing project folders by the click of a mouse and copy-pasting code between files/projects. I get that they're more portable than an IDE, but I only have one workstation so that's not a very strong point to me. To me these text editors feel more like a cult in which members embrace an obsolete technology. I mean, haven't we since invented graphic displays and mice?

Well, for a start there's CEDET, which if it were finished would be amazing. It's a touch buggy at the moment but it knocks every IDE I've used into a cocked hat. As for autocomplete, what you really want is dabbrev-expand, not having it for me is like being down a limb. I don't miss intellisense and it's code obscuring key grabbing nonsense at all. For project navigation ido is about a bajillion times faster at navigating your project as files than the IDE based hunting through a giant treeview nonsense.

Also, mice are older than Emacs IIRC, they are a terrible mistake in the development of computer interaction.

So yes, there are some things that "modern" IDE's do better than these obsolete text editors, but I just don't miss those features at all. I do miss dabbrev-expand and spell checking comments (flyspell-prog-mode) and strings when not using emacs. Not having to switch tools when editing python files and sql files is also great.

It does take a long time to learn how to use emacs well though. The best way is to pair with a more experienced user if you can find one. You will also be disadvantaged if you're using a language that has terrible deficiencies that can only be overcome by tools.

Adbot
ADBOT LOVES YOU

Zombywuf
Mar 29, 2008

Your Computer posted:

I mostly program in Java using Netbeans :downsgun:

Goondolances.

quote:

Another question; I've never actually tried emacs, though I've dabbled in vim. Are there any good* reasons why emacs is better?

org-mode

quote:

e: I'm one of those people who program in Java using an IDE on Windows. Should I even bother with stuff like vim and emacs?

Yes, org-mode. I tend not to use it much because I'm terribly disorganised. But it is still amazing.

Here's a video about it http://orgmode.org/talks/GoogleTech.html

Zombywuf
Mar 29, 2008

shrughes posted:

Good things about Emacs: it has modes for obscure programming language indentations that no other editor has. It is probably the best editor for Haskell. It is a better general purpose text editor than anything else (for small files).

I assume by small you mean less than several copies of War and Peace in size?

Also worthy of mention, nxml-mode is pretty great for editing XML files.

comedyblissoption posted:

I consider one of the greatest features in Emacs is that virtually everything is unified together in text buffers. You are not prevented from using the text editing and searching capabilities on any buffer window simply because it is a modal dialog or GUI widget.

Oh yeah, being able to search your compiler output, help text, REPL sessions, etc... using exactly the same bindings as everywhere else is excellent. Incremental search (C-s) is simply the best way to search.

Another fun thing is the number of places emacs bindings turn up, Bash for example and text entry widgets on the Mac.

Zombywuf
Mar 29, 2008

shrughes posted:

No, by small I mean smaller than a typical log file.

I wonder how typical your log files are. I don't find any problems under 10M and anything under 100M is still usable. Once you get beyond that you're pushing it though. I don't edit my logs that often though and when you get up to GB log files you should probably not be trying to read them by hand.

Zombywuf
Mar 29, 2008

Fren posted:



Using ido to jump quickly from method to method using incremental search.

I haven't seen this one, how's it done?

nm, seems to be from here http://nflath.com/2009/09/emacs-fixes/

Zombywuf fucked around with this message at 16:17 on Oct 2, 2011

Zombywuf
Mar 29, 2008

Fren posted:

Here's how I'm doing it on my system. I should add that while I can't
guarantee any of my code works in < Emacs 24, this should be fine in
23. https://gist.github.com/1257532

I had to make a small change to the code in that blog post which was possibly Emacs 23 related. It's a drat sexy thing.

Now I wonder if I can make it follow imports...

Zombywuf
Mar 29, 2008

Fren posted:

I might be starting to sperg.

A long time back I used to use Opera, and if I recall correctly it had a feature where it could sort of divine the navigation structure of a page, and find, say, "Next" and "Previous" page links in a forum thread. Then it had them bound to some simple shortcut so navigating a thread became scroll-scroll-scroll "next page"-shortcut without much hassle. The code below is just enough to accomplish the same thing in emacs-w3m:

I use vimium in Chrome which also does that.

Fun fact: There are defined html meta fields for this, no-one uses them :-(

Zombywuf
Mar 29, 2008

So working on a hosed Python codebase has lead to me creating this little function:

code:
(defun de-camel ()
  """CamelCaseIsEvilAndMustBeDestroyed"""
  (interactive)
  (while (looking-at "\\w")
    (let ((case-fold-search nil)
	  (c (char-after)))
      (if (char-equal (upcase c) c)
	  (progn
	    (insert "_" (downcase (char-after)))
	    (delete-char 1))
	(forward-char 1)))))

(global-set-key (kbd "C-x C-h") 'de-camel)
Now I can remove camel case in a fraction of the time.

Zombywuf
Mar 29, 2008

TasteMyHouse posted:

I want to be able to search through files using arbitrary regexes, but I want to exclude comments from the search. I also want to be able to search ONLY inside comments, and exclude code. Ideally this would be aware of any style of comment, based on the file extension

It's not ideal, but emacs regexps have escape sequences that match comment delimiters that should work in any language, so you can potentially search using these. Anything more than that requires advanced elisp skills. Well, advanced enough to iterate over comments and run search-forward-regexp on them while dealing with nesting.

Zombywuf
Mar 29, 2008

baby puzzle posted:

I tried emacs on osx and there was this enormous toolbar that I couldn't hide. How do you not have that thing?

code:
(if (boundp 'tool-bar-mode)
    (tool-bar-mode -1))
(menu-bar-mode -1)
Will get rid of the tool bar and menu bar. If you're using Aquamacs you may also want:

code:
(tabbar-mode -1)
Which gets rid of its retarded tabs.

Aquamacs wants these settings in ~/Library/Preferences/Aquamacs Emacs/Preferences.el, reqular Emacs in ~/.emacs. When you're editing the file, if you put the cursor just after each expression you can C-x C-e to run the expression.

Zombywuf
Mar 29, 2008

Fren, do you know of any way for compilation mode to understand tracebacks? Having next error jump through every line in the traceback is annoying. Or even better to understand the whole output of unittest (and run tests on a save hook)?

Zombywuf
Mar 29, 2008

Fren posted:

Gonna assume you're talking about running Python test suites with M-x compile. For pdb support I seem to be able to just open up a shell (C-x M-m) and run my nosetests test suite at the prompt. When pdb open up it seems to figure out where files are and starts PDB mode. Maybe try that with your unittest test suite?

Well, I'd also like for g++ "in file included from ..." chains to a appear as one error instead of half a dozen. Will give pdb a try for python though.

Zombywuf
Mar 29, 2008

comedyblissoption posted:

Why don't more people hit left ctrl with where their knuckle meets the palm rather than the pinky? People seem to go through a lot of hoops on windows to rebind ctrl to caps.

I can only assume your keyboard is a really weird shape. Even the mac has the option to remap your capslock in the keyboard preferences these days. Also emacs keybindings seem to work in most text entries, makes me wonder if Steve was a secret Emacs user.

Zombywuf
Mar 29, 2008

orphean posted:

You know how girls do window-shopping as a life-long regular activity? and some guys do window-shopping of cars? I don't need another keyboard, i already have plenty. But, i look at them, look for them, stare at them for hours, every week.

But, if you have a Kinesis all other keyboards become like empty husks of typing misery.

Zombywuf
Mar 29, 2008

shrughes posted:

I see you and raise you to Topre keyswitches.



Make the layout less cruel to fingers and I'll think about it.

Zombywuf
Mar 29, 2008

Beef posted:

Any changes that will make me more productive? I've got a deadline on Thursday and I need to soothe my conscience that it will be worth the switch :)

This is called Yak Shaving. Don't do it.

Zombywuf
Mar 29, 2008

Fren posted:

Also, the lexical binding stuff is pretty fantastic. I understand that this may be the beginning of writing code that doesn't block (i.e., waiting for the interface to respond after checking Gnus IMAP), though I'll admit I don't understand fully how the two concepts are related. Could you shed some light on that?

Asynchronous callbacks? Please say it's asynchronous callbacks. Then I can do flymake in tramp.

Zombywuf
Mar 29, 2008

pgroce posted:

It looks like the tricky bit is that the server file needs to be shared out-of-band. The source code for server-start also mentions a server-port variable, which might be useful if you need to punch through a (hopefully internal) firewall.

Sounds like this might be a job for sshfs.

Zombywuf
Mar 29, 2008

I wonder if emacsserver is a server in the same way that Xserver is a server. i.e. the server is supposed to be run wherever the user is sitting.

Zombywuf
Mar 29, 2008

The problem I have with org-mode is that I am not a natural note taker. I frequently try to use it but simply don't write enough stuff down. It is good at meetings though.

Anyone know any tools to pull information in to org-mode? I seem to have accounts on things all over the place, it would be cool if facebook/last.fm/google/etc... events could turn up in an org file somewhere.

Actually what I really want is a kind of web-based org-mode with multi user editing, a RESTful API for sharing parts and editing and embedding of arbitrary web content.

Also I want a pony.

Zombywuf
Mar 29, 2008

Fren posted:

Unfortunately, there aren't really any good tools for that sort of thing. But that's the benefit of them being in plain text -- just write some glue code and you can usually find a way to translate the information you need. For example! I wanted my OS X Address book contacts synced in Org, because I use org-contacts to autofill e-mail addresses. So I fired up Clozure CL (which has an Apple Foundation Framework bridge) and wrote some code to generate the Org file I wanted. (I have the bridge code for the address book up at https://github.com/ardekantur/nsclasp, but not the code that writes the Org file. I'll put that up in a bit.)

Oh man, whenever I start to try and write this kind of thing for a personal project I always end up over generalising. As in, never actually start for want of solving all the problems ever.

quote:

I really want to be able to provide a babel source like so:

code:
#+SRC lisp :filename ~/poop.lisp :lines 1 16
#+END_SRC
This also would rule.

quote:

Oh oh! I'm not a natural notetaker also, but Org-capture is the poo poo. From whatever buffer you're in, org-capture (which I think is C-c c by default), choose the template for your note, write it, and it gets filed away wherever you want it to go. Then at the end of the week or whatever you have some inbox.org filled with all your org-capture notes, and you can go through and refile/deal with them.

Seems I have some lovely default ubuntu version of org where this doesn't work. Hmm, time to upgrade perhaps.

Zombywuf
Mar 29, 2008

orphean posted:

It may seem daunting (its not!) but you could always build your emacs from source. I tend to track the bleeding edge but there's nothing stopping you from just downloading the officially released source tarball and using that.

I used to run Slackware. I've pretty much converted to "Give me package management or give me death." I could upgrade ubuntu but that runs into problems with my work machine being out of sync with the servers. Anyone know any good ppa's for emacs on Lucid?

Zombywuf
Mar 29, 2008

Fren posted:

Holy crap, I just discovered what I'm doing wrong with isearch. When you search for something and it's not found, but there's a prefix of your search string that *is* found, hitting C-g doesn't remove the search string, it removes everything after that prefix. That is, if I'm looking for `removed`, and there's only `rem` in the corpus, hitting C-g will turn the search string into `rem`, not the empty string. That makes so much more sense now.

drat I wish I'd known that sooner.

Zombywuf
Mar 29, 2008

Beef posted:

Moar emacs hints!

Y'all know about dabbrev-expand yes? M-/ will complete the current word using other words in your buffer and other buffers. I find it so much easier to use than Intellisense.

Zombywuf
Mar 29, 2008

Fren posted:

Hey thread. Does anyone know if there's a reasonably good Jira Emacs mode lying about? I hate having to lose context 10 or 12 times a day to go to that horrid website.

The only one I've found (jira.el) is pretty poor as it uses the xmlrpc interface which is very limited. So tempting to write a better one but :effort:.

Zombywuf
Mar 29, 2008

Anyone know how to get the current revision and other version control info from a file to create a org-capture template. The idea is to be able to insert a note about the file I currently have open, so something like this:
code:
(defun generate-file-template ()
  (let ((file-name (buffer-file-name))
	(line-number (line-number-at-pos)))
    (concat "* " file-name ":" (int-to-string line-number) " %T")))
will insert a note like:

quote:

** /home/zombywuf/code/dotfiles/src/.emacs:32 <2012-01-02 Mon 15:24>
What I want is to be able to check if the file is under version control and get info about the repository and revision but the functions under dvc don't seem to have much in the way of introspection. Anyone know how to get information out of it?

Zombywuf
Mar 29, 2008

Fren posted:

So far I've found vc-git-working-revision and vc-git-state, both of which take a filename as an argument. If you want the SHA1 hash, I'm sure vc-git.el has something that you can use.

The problem is I want it to work for git, hg and bzr. Ideally without duplicating a bunch of code that seems like it must exist within dvc somewhere.

Zombywuf
Mar 29, 2008

Awesome, that looks even better than what I was trying to do :-)

Zombywuf
Mar 29, 2008

DrMelon posted:

I just started using Emacs today, and I'm currently going through the little tutorial.

I can't stop. Send help.

There is no help, you are ours now. Join us.

tip: try M-/ for auto completion

Zombywuf
Mar 29, 2008

Also, how to get help:

C-h a - apropos, lets you search all the built in documentation
C-h b - opens a new buffer containing all the key bindings in the current buffer
C-h m - opens a new buffer with help for the current modes active (e.g. python-mode, help-mode, etc...)

The C-s search Mr. Fish mentions is extremely useful when it comes to the last 2 buffers. I usually explore new modes by searching through the help buffers that are opened. The function names that are displayed are hyperlinks you can follow with a mouse click or <enter>.

Also if you open the minibuffer for a command with M-x then you get tab completion of commands. The list of functions that appears when you hit tab twice is also searchable (you may be noticing a theme).

Zombywuf
Mar 29, 2008

More org mode fun. I've been playing with babel and I've just found out how to make it do SQL. A fairly common workflow for me is:

1) Oh it broke, maybe the clue is in the db.
2) Run a bunch of queries.
3) Curse my own stupidity.

Step 2 is often a pain as I often need to run a bunch of similar queries and keep a log of all the queries run and their output for reference. Org babel lets me do this by its "every language now has a workbook magic" and I'm guessing a lot of other people do so here's how. To do this for postgres you need a src block like this:
code:
#+begin_src sql :engine postgresql :cmdline mydbname
select * from stuff;
#+end_src
The :engine parameter tells ob-sql what sql engine to use, others available are mysql and msosql. The :cmdline parameter is just inserted into the command line of whatever program it is run under, for psql the first argument is the name of the db to connect to. With the point on this block I can just C-c C-C and the result of the query is inserted into the buffer as a table.

You can insert a src block by typing <s<tab> btw.

You can also use parameters, I'm using org mode 7.7, in 7.8 replace srcname with name. Parameters are delimited with a $ and are specified with :var param=value. Sadly it's just done with raw string insertion so features like using named tables as parameters are not going to work, to use a string as a parameter you need to double escape it like so:
code:
#+srcname: updatedsince
#+begin_src sql :engine postgresql :cmdline mydbname :var date="'2012-01-01'"
select * from stuff where updated >= $date;
#+end_src
If you run it with C-c C-c the default value will be inserted, to use other values insert a line into the buffer like so:
code:
#+call: updatedsince(date="'2012-01-10'")
and C-c C-c it. The result block inserted will have the params included so you can change the params and re-run and a new results block will be inserted.

Then comes babel's party trick, you can pass the output of one codeblock to the input of another, even across languages. For example:
code:

#+begin_src sql :engine postgresql
create table numbers (
  x int not null
);
#+end_src

#+results:
| CREATE TABLE |

#+begin_src sql :engine postgresql
insert into numbers (x) values (1);
insert into numbers (x) values (2);
insert into numbers (x) values (3);
#+end_src

#+results:
| INSERT 0 1 |
| INSERT 0 1 |
| INSERT 0 1 |

#+srcname: getnumbers
#+begin_src sql :engine postgresql
select x from numbers;
#+end_src

#+srcname: addone
#+begin_src emacs-lisp :var input=()
(mapcar
 (lambda (x)
   (+ (string-to-number (car x)) 1))
 (cdr input)) -- skip the header row
#+end_src

#+call: addone(input=getnumbers())

#+results: addone(input=getnumbers())
| 2 | 3 | 4 |
Org babel is a bit rough around the edges so it takes a bit of hassle to get it to work, hope this saves someone some time.

Zombywuf
Mar 29, 2008

ITYM C-e, but yeah, it's really cool when I suddenly realise I'm using those bindings outside of emacs and have been for ages. There's even a dabbrev-expand in readline which is not bound by default, enable it with:
code:
bind '"\e/":dabbrev-expand'
in your .bashrc.

Note: in SQL Server Management Studio C-e is "execute current buffer". Be very careful.

Zombywuf
Mar 29, 2008

You seem to have changed your tune on w3m Fren, how much effort is it to get it working?

Aside, sometimes certain things (flymake mostly) generate 2 line messages, which makes the window at the bottom move up one line. This can be really jarring, anyone know how to make the bottom window shrink instead of the top window shrinking and the bottom moving?

Zombywuf
Mar 29, 2008

I have fallen at the first hurdle, the ubuntu packages wont byte compile :-(

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.

Zombywuf
Mar 29, 2008

Gah, I'd love to know an answer to a similar question. Currently when I try to open any kind of file but an elisp file I get "End of file during parsing". Usually it fails to switch to the buffer for the file, but the file will open in a buffer. For SQL mode hooks will not have run, for python-mode they will. debug-on-error and debug-on-signal do not cause the debugger to open, using the -q argument (no init file) causes the error not to happen. Manually disabling hooks doesn't stop the error. I'm kinda stuck as to where to go from here.

(I'm running the emacs-snapshot for ubuntu 12)

Zombywuf
Mar 29, 2008

Zombywuf posted:

Gah, I'd love to know an answer to a similar question. Currently when I try to open any kind of file but an elisp file I get "End of file during parsing". Usually it fails to switch to the buffer for the file, but the file will open in a buffer. For SQL mode hooks will not have run, for python-mode they will. debug-on-error and debug-on-signal do not cause the debugger to open, using the -q argument (no init file) causes the error not to happen. Manually disabling hooks doesn't stop the error. I'm kinda stuck as to where to go from here.

(I'm running the emacs-snapshot for ubuntu 12)

Gah, so I found out why this was happening after much diagnosis. I found the problem went away when I used -q, but not when I commented out my whole .emacs file. I found that commenting out my entire .emacs file triggered a parsing bug in vc-mode which I don't even use. I also found that it had nothing to do with my .emacs file being a symlink to a git controlled version of the file.

Turns out I had been messing around with a .dir-locals.el file but had found it didn't do what I wanted but left it in a broken state. The end of file during parsing message was due to it trying to parse that file (which is apparently not loaded with -q), why I couldn't get it to trap in the debugger I don't know though.

Zombywuf
Mar 29, 2008

Last place I worked I did check that they didn't do any weird "you must use this editor" poo poo during the interview. I then spent several years learning how to write documents in Word and diagrams in Visio without slitting my wrists. I think it took a year for people to stop blaming my use of emacs for every svn corruption (which were caused by something else entirely).

Zombywuf
Mar 29, 2008

Fren posted:

You know, I don't really think Org-mode has a place in my life. It's too picky to be a universal markup language. Filtering out noise with agenda filters is too complicated to be practical. Literate programming is too primitive to handle complex development. TODO items are a pain in the rear end to be kept in sync with outside systems. Publishing a blog with it requires violent wrenching about in the innards of the module, and the default export systems are always just 90% there but for some glaring oversight in formatting. I like the default behavior for outlining, say, 50% of the time, and the other 50% are wrapped up in countless bizarre edge case options to understand and set.

I kind of agree with you. org-mode is still awesome for short term things like "I need to take notes in this meeting" but really starts to fall apart after 3 months of note taking all you have is a big pile of notes. The real thing that would make it shine would be a thing that lives outside of Emacs and syncs up all your note/tracking/issue data. But that's just one of my dreams of a brighter tomorrow.

I still use it as an ide for sql, it beats just about everything hands down there. In fact as a general "I need to do some coding for this one of task with a few scraps of shell, awk, python, sql, etc..." babel is pretty sweet. And when you realise you need to do it again a month later you have all your notes and code.

Adbot
ADBOT LOVES YOU

Zombywuf
Mar 29, 2008

org-babel would be awesome for SQL if org-mode weren't so drat slow at displaying tables. Just having a table in your buffer slows it down horribly.

  • Locked thread