Fork me on GitHub
#spacemacs
<
2017-11-03
>
novel14:11:01

I was also contemplating of switching to develop because of Parinfer, but it looks that 0.300 is almost ready for release: https://github.com/syl20bnr/spacemacs/blob/65d5e42b8ea603abe25cbf3a832a204c15aeedd8/core/info/release-notes/0.300.txt

orestis15:11:46

Is there a way to “stash” all open buffers so I can switch to a new project without accidentally open an unrelated buffer?

orestis15:11:22

In other editors I’d just start a new instance, but with emacs I do “emacsclient -n .” to open the current directory; the problem is, all my previous buffers are still there.

leo15:11:09

There is a M-x helm-persp-switch-project to create a new layer to your project, to switch between then use M-x layouts-transient-state

leo15:11:59

SPC p l and SPC l respectively

ag17:11:56

@U7PBP4UVA so this is little script I wrote awhile ago:

#!/bin/bash

    # Selected options for "emacsclient"
    #
    # -c          Create a new frame instead of trying to use the current
    #             Emacs frame.
    #
    # -e          Evaluate the FILE arguments as ELisp expressions.
    #
    # -n          Don't wait for the server to return.
    #
    # -t          Open a new Emacs frame on the current terminal.
    #
    # Note that the "-t" and "-n" options are contradictory: "-t" says to
    # take control of the current text terminal to create a new client frame,
    # while "-n" says not to take control of the text terminal.  If you
    # supply both options, Emacs visits the specified files(s) in an existing
    # frame rather than a new client frame, negating the effect of "-t".

    # check whether an Emacs server is already running
    pgrep -l "^Emacs$" > /dev/null

    # otherwise, start Emacs server daemon
    if [ $? -ne 0 ]; then
                 ## get the path to emacs-app
        open -g $(brew info emacs-plus | sed -n '4p' | sed 's/ .*$//g')/Emacs.app
        sleep 15
        emacsclient -e "(progn (persp-add-new \"$(pwd)\") (persp-switch \"$(pwd)\"))"
        # exit 1
    fi

    # return a list of all frames on $DISPLAY
    emacsclient -e "(frames-on-display-list)" &>/dev/null

    # open frames detected, so open files in current frame
    if [ $? -eq 0 ]; then
        emacsclient -e "(progn (persp-add-new \"$(pwd | grep -o '[^/]*$')\") (persp-switch \"$(pwd | grep -o '[^/]*$')\"))"
        emacsclient -n -t $*
    # no open frames detected, so open new frame
    else
        emacsclient -e "(progn (persp-add-new \"$(pwd | grep -o '[^/]*$')\") (persp-switch \"$(pwd | grep -o '[^/]*$')\"))"
        emacsclient -n -c $*
    fi

ag17:11:58

if you put it say in ~/.ec and `alias ec='~/.ec'` then you can do something like cd ~/proj &amp; ec .

ag17:11:24

it will create a spacemacs layout for the project

orestis17:11:51

Wow thanks! I’ll test it out ASAP.

ag17:11:26

the script can be improved - I just haven't had time to do it. I've been using eshell lately, so I almost don't use it anymore

eggsyntax15:11:00

I actually do generally start new instances for separate projects, although I'm sure there's a more emacsy way to do it.

ag17:11:17

@eggsyntax use layouts aka perps

bja18:11:13

everyone is excited about parinfer and I'm 95% fed up with lisp state enough to attempt porting vim-sexp

bja18:11:27

that's the only part of vim I miss

jeff.terrell18:11:00

I haven't heard of vim-sexp before. What are your pain points for evil-lisp-state @bja?

bja18:11:12

that it doesn't compose very well with evil

ag18:11:42

@bja have you tried cleverparens?

ag18:11:54

I haven't tried myself, just asking

bja18:11:57

@ag I have not, I'll give that a try

ag18:11:21

there's an official layer for spacemacs

jeff.terrell18:11:57

@bja - I don't have that pain at present, but I'm definitely open to an alternative approach. I may just not know what I'm missing.

bja18:11:51

I used vim for about 15 years. I've become very accustomed to using motions and operators as the basics of my editing experience. vim-sexp added sexp-aware motions

jeff.terrell18:11:04

You have my attention.

jeff.terrell18:11:33

That does sound cool.

bja18:11:08

the default lisp-state mostly works

ag18:11:11

@bja anything vim can do we can do better. (like in the song) 😉

bja18:11:22

like, once you define an eval operator

bja18:11:34

you can just enter visual state and use lisp-mode to select whatever

bja18:11:40

and then invoke the operator

bja18:11:55

and you can still do things like select a couple graphs and send them via the operator

bja18:11:27

but selecting something in VISUAL is a wasted extra step.

eggsyntax18:11:36

@bja I've got an eval-region defined; I can dig that up if you want.

bja18:11:49

I have a generic eval-region

eggsyntax18:11:56

Although I haven't ended up using it much.

bja18:11:40

but the paint point is that I want to select using evil commands without prefixing everything with a V so that my selection is put somewhere something like cider-eval-region can find it

jeff.terrell18:11:43

Like <eval-motion>a) to evaluate the present s-expression?

bja18:11:44

I can do this pretty easily:

(defvar spacemacs--generic-eval-region-alist
  '((clojure-mode . cider-eval-region)
    (emacs-lisp-mode . spacemacs//emacs-lisp-eval-region-and-print)
    (python-mode . python-shell-send-region)
    (lisp-mode . lisp-eval-region)))

(defun spacemacs//get-eval-region-for-current-mode ()
  (interactive)
  (catch 'break
    (dolist (test spacemacs--generic-eval-region-alist)
      (let ((mode (car test))
            (val (cdr test)))
        (when (and (symbolp mode)
                   (derived-mode-p mode)
                   (symbolp val))
          (throw 'break val))))))

(defun spacemacs//generic-eval-region (beg end)
  (interactive)
  (let ((f (spacemacs//get-eval-region-for-current-mode)))
    (when (functionp f)
      (funcall f beg end))))

(evil-define-operator spacemacs//generic-evil-eval-operator (beg end)
  (spacemacs//generic-eval-region beg end))

bja18:11:52

I bind it to something else, but yeah

bja18:11:22

the thing is, I want better support for motions in ways that are more natural to evil

bja18:11:58

(I define the stuff generically because I hate having separate keybindings for different languages)

eggsyntax18:11:59

Yeah, I've got a pretty similar eval-operator defined, but it's not great with recognizing the beginnings and ends of sexps.

eggsyntax18:11:51

So I can do, eg <alt> e % from a paren to say (effectively) eval around paren, but it's a bit wonky.

bja18:11:09

I do V%<EVALOP> a lot

bja18:11:22

but I can also do , , %

bja18:11:29

which is my eval operator

eggsyntax18:11:39

so I don't actually need to use visual mode...another example, I can do <alt> e a ] for eval-around-square-brackets, or <alt> e $ for eval to end of line. Is that how yours works as well? I'm just not clear on the issue w/ visual mode.

eggsyntax18:11:08

(I could decipher it from your code, but it'd take me a while, my emacs-lisp-fu isn't that hot)

bja18:11:33

I think mine does the same thing (I just tested ,,a] )

eggsyntax18:11:57

That's the best I've been able to do; if you find something better, I'd love to hear abuot it.

bja18:11:59

but the selection of sexps isn't as crisp as I'd like in evil. Maybe cleverparens can help with that

jeff.terrell18:11:37

I learned a few things about elisp by reading your code, @bja. Thanks for sharing that.

eggsyntax21:11:06

Crap, I'm sorry, I totally misled folks yesterday. The built-in SM structural editing, built on top of paredit, is smartparens, not cleverparens. cleverparens is something totally different (which seemed cool but conflicted with too many bindings for me personally). I just got thrown off by the names being so similar. @ag @drewverlee https://practicalli.github.io/spacemacs/structured-editing/

ag21:11:31

yeah no worries.... Emacs naming is brutal.

ag21:11:20

barf 'n slurp 'n kill n' yank. ahoy!

practicalli-johnny23:11:03

I should be doing more work on practicalli spacemacs over the winter holidays. I've got a lot of notes to add 🙂