Tag: emacs

  • Uniquify your Buffer Names in emacs with use-package

    Recently I have been working on projects that often have multiple files of the same name. By default emacs doesn’t give much information to help you switch between the buffers of open files of the same name. At the same moment that I was thinking I need to find a solution to this Pragmatic Emacs posted a nice little solution using uniquify.
    This is how do the same using use-package:

    (use-package uniquify
      :config
      (setq uniquify-buffer-name-style 'forward)
      (setq uniquify-separator "/")
      (setq uniquify-after-kill-buffer-p t)    ; rename after killing uniquified
      (setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
      )
    

     

  • installing emacs in cygwin

    Update: See my other post, launching emacs from cygwin
    There are a few tricks to installing emacs in cygwin. Here’s what I do.

    Installing cygwin

    First, install cygwin.
    Then, install the very nice tool apt-cyg which makes package management much easier in cygwin.
    Then to save yourself lots of agony of trying to work out which cygwin packages you need to install to be able to compile emacs, here is the list of all the packages I have installed. It may be a little bit of overkill but it will save you time. I obtained the list like this:

    jason@jade ~
    $ apt-cyg show | tr '\n' ' '

    Install them with:

    $ apt-cyg install
    _autorebase _update-info-dir alternatives autoconf autoconf2.1 \
     autoconf2.5 automake automake1.10 automake1.11 automake1.12 \
    automake1.4 automake1.5 automake1.6 automake1.7 automake1.8 \
     automake1.9 base-cygwin base-files bash bash-completion bc binutils \
    bzip2 ca-certificates cmake coreutils cpio crypt csih curl cvs cvsps \
    cygrunsrv cygutils cygwin cygwin-doc dash dbus diffutils dos2unix \
    editrights file findutils gamin gawk gcc-tools-epoch1-autoconf \
    gcc-tools-epoch1-automake gcc-tools-epoch2-autoconf \
    gcc-tools-epoch2-automake gcc4 gcc4-core gcc4-g++ gccmakedep gettext \
    gettext-devel git git-completion git-gui git-svn gitk gitk grep groff \
    gsettings-desktop-schemas gsettings-desktop-schemas gzip imake \
    ipc-utils less libX11_6 libX11_6 libXau6 libXau6 libXdmcp6 libXdmcp6 \
    libXext6 libXext6 libXft2 libXft2 libXrender1 libXrender1 libXss1 \
    libXss1 libapr1 libapr1 libaprutil1 libaprutil1 libasn1_8 libattr1 \
    libblkid1 libbz2_1 libcharset1 libcloog0 libcom_err-devel libcom_err2 \
    libcurl-devel libcurl4 libdb4.5 libdb4.5-devel libdb4.5-devel libdb4.8 \
    libdb4.8 libdbus1_3 libdbus1_3 libedit0 libedit0 libexpat1 libfam0 \
    libfam0 libffi4 libfontconfig1 libfontconfig1 libfreetype6 \
    libfreetype6 libgcc1 libgcrypt11 libgdbm4 libgettextpo0 libgettextpo0 \
    libggi2 libggi2-display-terminfo libgii1 libgii1 libglib2.0_0 \
    libglib2.0_0 libgmp3 libgmpxx4 libgnutls26 libgomp1 libgpg-error0 \
    libgssapi3 libhdb9 libhdb9 libheimbase1 libheimntlm0 libhx509_5 \
    libiconv libiconv libiconv2 libidn-devel libidn-devel libidn11 \
    libintl8 libkadm5clnt7 libkadm5clnt7 libkadm5srv8 libkadm5srv8 \
    libkafs0 libkafs0 libkdc2 libkdc2 libkrb5-devel libkrb5-devel \
    libkrb5_26 liblzma5 liblzo2_2 libmetalink3 libmpc1 libmpfr1 libmpfr4 \
    libncurses-devel libncurses10 libncurses7 libncurses8 libncurses8 \
    libncurses9 libncurses9 libncursesw-devel libncursesw10 libneon27 \
    libneon27 libopenldap2_3_0 libopenldap2_3_0 libopenldap2_4_2 \
    libopenssl098 libopenssl100 libp11-kit0 libpcre0 libpcre1 libpcre1 \
    libpopt0 libppl libpq-devel libpq-devel libpq5 libpq5 libproxy1 \
    libproxy1 libreadline6 libreadline6 libreadline7 libroken18 libsasl2 \
    libsasl2-devel libsasl2-devel libserf0_1 libserf0_1 libserf1_0 \
    libserf1_0 libsigsegv2 libsl0 libsl0 libsqlite3_0 libssh2-devel \
    libssh2-devel libssh2_1 libssp0 libstdc++6 libstdc++6-devel libtasn1_3 \
    libuuid1 libuuid1 libwind0 libwrap0 libxcb1 libxcb1 libxml2 login m4 \
    make makedepend makedepend man mintty nano ncurses ncurses-demo \
    ncursesw ncursesw-demo openldap-devel openldap-devel openssh openssl \
    openssl openssl-devel openssl-devel perl perl-Error \
    perl-Locale-gettext perl_vendor python rebase run sed stgit subversion \
    subversion subversion-perl subversion-perl tar tcl tcl tcl-tk tcl-tk \
    termcap terminfo terminfo-extra terminfo0 terminfo0 terminfo0-extra \
    texinfo tzcode unzip util-linux w32api w32api-headers w32api-runtime \
    wget which xorg-cf-files xorg-cf-files xz zlib zlib-devel zlib-devel \
    zlib0

    Go and have a cup of tea while its installing.

    git clone git://git.savannah.gnu.org/emacs.git
    cd emacs
    ./configure --with-w32 #  to ditch gtk and the concomitant gtk bug, thanks jlf
    make

    If make is successful, test the build by running emacs from the src directory:

    src/emacs -Q

    If that worked ok, you can:

    make install

    Setting up your home

    I like my cygwin home directory to be the same as windows %USERPROFILE% so I set the environment variable HOME=%USERPROFILE%.

    Set up a shortcut to launch emacs

    Make a shortcut to c:\cygwin\bin\run.exe on your desktop, and rename it to emacs.
    Edit the shortcut to:
    Target: C:\cygwin\bin\run.exe /usr/local/bin/emacsclient "-c" "-a" "/usr/local/bin/emacs.exe" #
    Start in: %USERPROFILE%
    The target part makes sure emacs launches a new window whether or not its already running. If it is already running and as a server, it will create a new frame connected to the server.
    The start in part makes sure the new instance’s default-directory is your home directory which I think makes most sense for when you are launching from a shortcut.
    Drop the shortcut onto your start menu. You should now be able to launch emacs from the start menu, or by pressing the Windows key and typing emacs.

  • Edit a regex search string in Emacs

    If you are writing a complex regex search in emacs and need to edit the string, arrow keys takes you out of the search. M-e allows you to really edit the string.

  • Swap Registers in emacs calc

    <TAB> to swap theĀ contentsĀ of the last two registers in calc.

  • Select what you typed rather than the completion in ido-mode

    Sometimes you don’t want the completion that ido is offering me in Emacs, for instance when trying to create a temporary buffer C-x C-b sometempbuffername. C-j will to get ido to accept what you typed rather than the completion.

  • Insert a new heading after numbered list in org-mode

    In org-mode in emacs, M-<RET> will add either a new heading or if your insertion point is between a list item and a heading, it will add a new list item. This is not always desirable. To add a new heading try C-U M-<RET>.
    I only discovered this as I got frustrated with org-mode insisting on adding an item to the list rather than creating a new heading. The emacs way around problems like this is to prefix the command with C-U to make it do something slightly different.

  • removing historical buffer names from the ido buffer list

    ido-mode in emacs has this great feature where it remembers old buffers you have had open in the past and offers then as choices when switching buffer using C-x b. The problem is that sometimes it will have names in the list you’d rather it didn’t remember. The solution is easy, simply hit C-k to instantly kill the entry under point.

  • gnus, imap and gnutls in win32

    I’ve been trying to get gnus working in emacs in win32 for the past few days. There were a number of obstacles to overcome:

    1. Install gnutls
    2. The gnus README.w32 says gnutls should be installed and in the path. I found that it must be in the windows system path to make it work. Setting the path within emacs was not good enough. So add C:\Program Files (x86)\gnutls\bin;C:\Program Files (x86)\gnutls\lib to your system path by going to Start/Edit System Environment Variables then click Environment Variables and edit Path in System Variables
    3. you need to edit the emacs variable gnutls-trustfiles to point to windows paths to .crt files. by default it had paths to unix locations. The only way I could find to get these files was to install cygwin and then make gnutls-trustfiles equal to ("C:/cygwin/usr/ssl/certs/ca-bundle.trust.crt" "C:/cygwin/usr/ssl/certs/ca-bundle.crt")

    Unfortunately these last two steps were not obvious to me and it took me quite some time to work through them.
    Tip: if you need to debug gnutls, try setting (setq gnutls-log-level 50).
    Now all I need to do is learn gnus!