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
aerique
Jul 16, 2008
So, what completion engines are people running here that they are happy with?

I've been using Helm (was: Anything) for more than a year now and am pretty content with it. I'm also still using auto-complete.el and Slime's own fuzzy completion (because ac-slime was slow as gently caress) and once I have consolidated the latter two into Helm it should all feel a little more consistent.

The one thing I would like is for the Helm buffer to open in the biggest available other-window, but I haven't been able to write a correct elisp function for that.

(Written on mobile so I can't be bothered to check for the correct names and provide URLs, sorry...)

Adbot
ADBOT LOVES YOU

aerique
Jul 16, 2008
This is cute, changing values with the mouse: http://nullprogram.com/blog/2013/06/07/

Although I've found (with playing with Unity lately and preferring haXe) that I'm much more of a 'code' person and less visually inclined than I thought.

aerique
Jul 16, 2008
I've got a problem with for loops in eshell.

If I do:

code:
for GPLOT in gnuplot_scripts/*.gplot { echo "Processing $GPLOT..." }
It'll echo all the scripts in the directory like it should, but if I do:

code:
for GPLOT in gnuplot_scripts/*.gplot { echo "Processing $GPLOT..." ; gnuplot $GPLOT 1> /dev/null 2> /dev/null }
It'll go into an infinite loop processing just one specific file. It'll do the same if I leave out the echo command.

Googling hasn't helped much, anyone got an idea?

aerique
Jul 16, 2008

h_double posted:

What happens if you leave out the 1> and 2> redirects? Does gnuplot STDOUT/STDERR report anything interesting?

No, it just reports some default progress on the script.

(BTW. Your cat example worked fine for me as well.)

Oh well, nevermind. The case I needed it for at work is in the past now so it isn't really relevant anymore. I switched to using multi-term.

aerique
Jul 16, 2008

aerique posted:

The one thing I would like is for the Helm buffer to open in the biggest available other-window, but I haven't been able to write a correct elisp function for that.

I managed to get this working. If anyone's interested I can put the code up on pastebin.

I've been meaning to put my config on GitHub but for sharing purposes I don't really like the state my config is in.

aerique
Jul 16, 2008

pgroce posted:

I spent a ton of time a few months ago building a config with sensitive info (i.e., IP addresses, user names) in one file and the generic stuff in another, just so I could put it up on github or bitbucket or whatever. Still haven't done it. :effort:

I even set things up in org-mode. :sigh:

I've been tempted to redo my config in org-babel like Sacha Chua did: https://dl.dropboxusercontent.com/u/3968124/sacha-emacs.html (from: http://sachachua.com/blog/2012/06/literate-programming-emacs-configuration-file/)

However, just separating the sensitive stuff from the other config options is something I should have done long ago and would give me immediate benefits.

aerique
Jul 16, 2008

Not only that, my Sacha Chua emacs-org-config suggestion apparently came from this thread as well :downsgun:

Those per-machine configs are nice though. I feel some config work coming up in the near future.

aerique
Jul 16, 2008

h_double posted:

The package works great except for one thing, I would like to be able to scroll back through my command history in the R console.
...
Am I missing something simple/stupid?
Have you tried M-p and M-n? It might be because I haven't had my morning coffee yet but AFAIK those keys are the defaults for moving back and forward through history for a lot of modes.

You can also do "C-h m" (describe-mode) to see what keys are bound for the mode, maybe it's listed there.

aerique
Jul 16, 2008

Opinion Haver posted:

If I have some 'template' that looks like

code:
void foo_X(int Y);
and I want to insert this multiple times with different values for X and Y, what's the easiest way to do that?

I'm not sure it is the easiest but YASnippet is a nice templating library that will be able to do this.

http://ergoemacs.org/emacs/yasnippet_templates_howto.html

Here's an example I made for xsl:choose:

code:
#name : xsl:choose
# --
<xsl:choose>
  <xsl:when test="$1">
    $0
  </xsl:when>
  <xsl:otherwise>
    $2
  </xsl:otherwise>
</xsl:choose>
Your template would look something like this (untested):

code:
#name : void_foo
#--
void foo_$1(int $0);
IIRC, $0 is where you want the cursor to end up once the template is inserted. $n (n>1) are fields you can step through with TAB before ending up at $0.

aerique
Jul 16, 2008
I've got this for Python mode:

code:
(add-hook 'python-mode-hook
          (lambda ()
            (when (at-work)
              (setq indent-tabs-mode t
                    show-trailing-whitespace nil
                    tab-width 4))
            (whitespace-mode 1)))

aerique
Jul 16, 2008
I don't use a package manager for Emacs so take this for what it's worth.

PlesantDilemma posted:

I see both a yasnippet and sublime folder under .emacs.d/elpa/ should I delete those folders?

You could start with just moving / renaming the folder and see how that goes. There's probably some init file somewhere loading those so Emacs will still complain it can't find sublime and yasnippet.

I have no idea where the package manager stores its configuration but doing a
code:
egrep -Iir sublime\|yasnippet .
in the .emacs.d directory or your home directory should give you some pointers.

aerique
Jul 16, 2008

PlesantDilemma posted:

Hey, does anyone use keybindings other than M-w and C-w for copy/cut ? I don't like M-w for copy, but I don't know what other keybinding to use. I'm afraid I'll overwrite something useful that I just don't know about yet.

Don't be afraid of that. Emacs is meant to be customized.

I've been using a evil-mode for a couple of years now which gives me Vim-like behavior, before that I had extensive custom keybindings of my own. The last iteration of which converged to what is considered default for standard Windows and Linux apps. So C-z, C-x, C-c, C-v for undo, cut, copy and paste. C-a for selected all. C-PgUp and -PgDn for cycling through tabs, etc. etc. It was nice but I had used Vim in the past and preferred that.

Before that I had really my own custom bindings which were pretty optimal and nice but too different from other apps which irked me.

aerique
Jul 16, 2008
A reason to get familiar with the Emacs defaults would be that the Bash[1] shell uses them as well, but those can be rebound as too.

[1] the readline library actually so the key bindings return in more apps

aerique
Jul 16, 2008

Surprise T Rex posted:

So I grabbed Emacs yesterday after getting frustrated with the poor state of Python Autocompletion in Sublime Text compared to C#'s IntelliSense in VS2013. I sort of came into it with the mindset of "Well I'll pick either Emacs or Vim to have a go at learning, and if I can't wrap my head around it then I'll give in and keep going with ST3."

For Python completion I use Jedi (https://github.com/davidhalter/jedi) and for syntax checking I use Flycheck (https://github.com/flycheck/flycheck).

Try out Jedi.el first. I personally use anaconda-mode because I use company-mode as my generic completer but I recall Jedi.el to be easier to setup initially.

There's also a couple of all-in-one Python packages for Emacs. I tend not to like such solutions but to each his own: http://www.emacswiki.org/emacs/PythonProgrammingInEmacs#toc2

Surprise T Rex posted:

Last night I felt like I might be about to give in, but I loaded it up at work today and just casually opened up my .emacs, took out the scroll and toolbars, saved it and had a look around the buffer menu and stuff, without needing to think too much. It's... not easy, I guess, just not quite as incomprehensible as I first thought it might be.

Yeah, like others already said gently caress that poo poo. I don't use hjkl in Vim much either: touch typists ain't got swag.

Seriously, maybe it's because I did a lot of swimming when I was younger but the homerow, touch typist position has always felt very cramped when I tried it. I keep my hands floating at the sides of the keyboard near WASD and the arrow keys so I have no problem using the arrow keys and Ins / Del / Home / End / PgUp / PgDn.

aerique
Jul 16, 2008

fidel sarcastro posted:

I keep an Exuberant Ctags file in my .git directories that's updated with Git hooks on commit/checkout. Vim would automatically pick that up thanks to some magic in the Fugitive plugin and use it for navigation and completion. Is there any way to have Emacs automatically grab it? (I've already updated the Git hook to generate an Emacs compatible tags file, and selecting it manually works).

I think I've seen a page on the EmacsWiki about updating tags on saving the buffer but I haven't used it myself (yet, I've been meaning to).

Ah, here. Not quite what I thought it was but hopefully some inspiration for your first elisp project ;-) http://www.emacswiki.org/emacs/GnuGlobal#toc3

fidel sarcastro posted:

In Vim I had the tab key remapped to send tab if the cursor was beside a line beginning or whitespace character, and call a completion function otherwise. Should that be possible to duplicate?

Yes, there's a couple of solutions. Check this page which seems to have grown since the last time I checked it: http://www.emacswiki.org/emacs/TabCompletion

I've used Smart Tab for a while but thought it too complex for what it was supposed to do. For now I'm using my own solution (pasted below) but perhaps I should check out the new entries on that page.

code:
;; I wasn't really happy with how Smart Tab worked and its complexity, so I reinvented the wheel
;; which does what is intuitive to /me/.  It will have issues for people not used to it.
(setq tab-overload-completion-function #'company-complete)
(setq tab-overload-debug nil)

(defun tab-overload-complete ()
  "Complete according to current major mode."
  (interactive)
  (when tab-overload-debug
    (message "  tab-overload-complete"))
  (funcall tab-overload-completion-function))

(defun tab-overload-indent ()
  "Indent region if mark is active, or current line otherwise."
  (interactive)
  (when tab-overload-debug
    (message "  tab-overload-indent")
    (message "  use-region-p: %s; bolp: %s; string-match(%s): \"%s\" <<%s>>"
             (use-region-p) (bolp)
             (string-match "[[:space:]]" (string (preceding-char)))
             (string (preceding-char)) (preceding-char)))
  (if (use-region-p)
      (indent-region (region-beginning) (region-end))
      (indent-for-tab-command)))

(defun tab-overload ()
  (interactive)
  (when tab-overload-debug
    (message "tab-overload"))
  (if (or (use-region-p)
          (bolp)
          (string-match "[[:space:]]" (string (preceding-char))))
      (tab-overload-indent)
      (tab-overload-complete)))

(define-key evil-insert-state-map (kbd "<tab>") 'tab-overload)
(define-key evil-visual-state-map (kbd "<tab>") 'tab-overload)

aerique
Jul 16, 2008

horse mans posted:

The Emacs Stackoverflow is in beta, which is good. It seems to only be restricted to the people who voted for it, which is goddamned loving retarded.

If there's questions you want asked on there you can ask them through me. It's mostly about traffic currently to get the from beta to official.

aerique
Jul 16, 2008

horse mans posted:

Exactly. So why wouldn't they open it up to everyone in order to increase chances the traffic reaches that point?

I have no clue. I was just offering a way to add to the traffic if you want the site to become official.

aerique
Jul 16, 2008
I've put my own Emacs theme online which is a little bit different from most themes: the point is not so much to highlight every syntax under the sun, but use the highlighting to partition the source in easily scannable pieces: https://github.com/aerique/emacs-theme-aerique

I've always found themes that highlight too much, distracting and to not offer much above no syntax highlighting at all. Not too mention the colors are often too intense. So the theme just highlights the usual suspects like comments and strings (which are often a source of errors when not closed).

It isn't really ready for public consumption yet though since it has an issue: it needs to be loaded twice. This is probably due to the theme inheriting from its own definitions. Does anyone have an elegant solution to this without putting variable names for custom colors in the global namespace?

aerique
Jul 16, 2008

tak posted:

the recommended way of doing both ido and helm is to globally enable helm and add ido wherever you prefer it. Anyone use both? Is it worth sticking with ido in general?

I don't really see the point of using both. I used ido + smex for quite a while before helm got on the radar and I switched to the latter two years ago.

aerique
Jul 16, 2008

midnightclimax posted:

Anyone using mu4e as the standard mail client? Worth checking out/not worth the hassle?

I have used it at work in the past and really like it. Nimble and configurable. Definitely worth checking out.

Have been planning to set it up again when there's a slow Friday afternoon at work.

aerique
Jul 16, 2008

midnightclimax posted:

How does it compare to mutt? Similar scope of abilities or more basic?

The base install is more basic than mutt, but mutt doesn't have Emacs behind it.

Mu4e's approach to mail is also different from mutt, see the mu mail tools.

aerique
Jul 16, 2008

midnightclimax posted:

I'm currently playing around with Icicles, which makes me wonder, are there any libraries that you would consider essential?

You might want to check out helm before investing too much time in Icicles.

aerique
Jul 16, 2008

duck hunt posted:

Is the process the same for adding similar functionality for other languages, or is Python special because, well, its Python and everyone loves it?

It different for each language.

aerique
Jul 16, 2008

MALE SHOEGAZE posted:

OK so, I'm about 4 days into using evil and I like it but it feels like the model I use to manage buffers doesn't really work with emacs.

Basically, I rebind shift and left/right to move to the previous/next buffer. Then I use lots of splits and use up/down/left/right to navigate the splits. The problem is that emacs/helm makes tons and tons of buffers so rather than left/right navigating through the stuff i'm working on, it navigates through buffers that I can't even use because they're just storing something for helm.

I'm 100% sold on emacs otherwise but this is just killing me. What am I doing wrong?

You're not necessarily doing anything wrong, you just need to adapt Emacs to your preferences. I also use (alt-)up/down/left/right to navigate splits, I've also got a key bound to quickly switch back to the previous buffer and I have customized the "display-buffer-alist" variable (check what it does using "C-h v" or "M-x describe-variable"). The latter makes sure specific buffers open where and how I want them to.

I'll paste the code below but it's not really for public consumption: it has never been run by anyone but myself.

code:
(global-set-key (kbd "C-<backspace>") 'switch-to-last-buffer)

;; This is a work in progress and currently a whitelist.
;; FIXME gives problems on Windows and OS X (older Emacs 24?)
(when (on-unix)
  ;; What about display-buffer-base-action?
  (setq display-buffer-alist
        '(("*Buffer List*"  . (display-buffer-largest-other-window . nil))
          ("*cscope*"       . (display-buffer-largest-other-window . nil))
          ("*grep*"         . (display-buffer-largest-other-window . nil))
          ("*Help*"         . (display-buffer-largest-other-window . nil))
          ("*helm.*"        . (display-buffer-largest-other-window . nil))
          ;(".*imenu*"       . (display-buffer-pop-up-window        . nil))
          ("*Ibuffer*"      . (display-buffer-largest-other-window . nil))
          ("*Man .*"        . (display-buffer-largest-other-window . nil))
          (".*"             . (display-buffer-largest-other-window . nil)))))

(defvar switch-to-last-buffer-hash-table (make-hash-table))

(defun switch-to-last-buffer-store ()
  (interactive)
  (puthash (selected-window) (current-buffer)
           switch-to-last-buffer-hash-table))

(defun switch-to-last-buffer ()
  (interactive)
  (let ((last-buffer (gethash (selected-window)
                     switch-to-last-buffer-hash-table)))
    (when last-buffer
      (switch-to-last-buffer-store)
      (switch-to-buffer last-buffer))))

;; XXX What does /protected/ do?
(ad-add-advice #'switch-to-buffer '(switch-to-last-buffer-store nil t (lambda () (switch-to-last-buffer-store))) 'before 'first)

;; Use #'get-largest-window: [url]https://www.gnu.org/software/emacs/manual/html_node/elisp/Cyclic-Window-Ordering.html#Cyclic-Window-Ordering[/url]
(defun display-buffer-largest-other-window (buffer alist)
  "Display BUFFER on the same frame in the largest window (currently
only the height is checked) that is not currently the active window."
  (let ((sorted-windows (sort (loop for w in (window-list) collect w)
                              (lambda (a b)
                                (> (window-height a) (window-height b))))))
    (catch '--cl-block-display-buffer-largest-other-window--
      (loop for sw in sorted-windows
            do (unless (or (equal sw (selected-window))
                           (window-minibuffer-p sw)
                           (window-dedicated-p sw))
                           (window--display-buffer buffer sw 'reuse)
               (return-from display-buffer-largest-other-window sw))))))

aerique
Jul 16, 2008

Phobeste posted:

Emacs python-mode [...]

Anybody run into something similar?

More-or-less, but no solution.

I also use the default Python mode, with FlyCheck and company-anaconda for autocompletion. Turning off FlyCheck seems to alleviate the slowdowns somewhat but I'm actually not sure whether it's just an illusion.

Not really a helpful reply but at least you now known you're not alone out there.

Perhaps try out another Python mode?

aerique
Jul 16, 2008

eschaton posted:

Let's say you start using a new mode because you're learning a new language or something. Among other things it'll have its set of key bindings to learn. They'll probably build on existing emacs bindings.

I've rarely found this to be an issue.

The bindings that come with modes are almost universally crap just like the default Emacs bindings are and you'll never use all the bindings that come with a mode anyway.

Just "C-h m" and bind the ones you need to something useful.

aerique
Jul 16, 2008
Well, I guess there's one advantage to not using the Emacs package manager.

aerique
Jul 16, 2008

Dessert Rose posted:

With vim keybindings, C-] also exits insert mode. I rarely use esc for it.

That's the only downside to being a Lisp hippy and switching the brackets and the parens: no C-] :-(

aerique
Jul 16, 2008
Why not mention Spacemacs as well as a batteries-included Emacs?

Perhaps for people looking to decide between Vim and Emacs.

aerique
Jul 16, 2008

duck monster posted:

When I use Ctl-3 to split the window, whenever I click the right window it kind of flips out and pulls some sort of menu completion thingo down the bottom

Maybe a screenshot if you get no reactions? It doesn't sound familiar to me.

Adbot
ADBOT LOVES YOU

aerique
Jul 16, 2008

mike12345 posted:

Is there a way to cycle through the places where you changed a file, after you've closed and reopened it? Basically I press a button and it keeps jumping to the positions I edited last time.

The smart-rear end answer would be diff-hl and its diff-hl-next-hunk and diff-hl-previous-hunk commands.

Seriously, I'm not aware of a package that keeps this state around although it might not be too hard to add it to goto-last-change.

  • Locked thread