all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* browsing files in huge projects emacs
@ 2013-09-27 10:48 anurag Ramdasan
  2013-09-27 10:52 ` Sebastien Vauban
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: anurag Ramdasan @ 2013-09-27 10:48 UTC (permalink / raw)
  To: help-gnu-emacs

Hey,

I have been using Vim for a while although I would shift to E..macs for Org-mode and Slime. When I end up working on a huge project with hundreds or even thousands of files, I found the nerdtree vim plugin to be the best thing to suit my ways. Also I find dired a little difficult to browse through.

So when I recently gave thoughts to completely moving to emacs, I couldn't find anything as good as Nerdtree. I did find dirtree but it didn't seem as easy to use as nerdtree. This made me wonder, how do most emacs users navigate through huge projects? Is there some common practice or some plugin that I haven't heard of yet? Also I use both vim and emacs from the terminal and not the GUI client.

Thanks.
- AR.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: browsing files in huge projects emacs
  2013-09-27 10:48 browsing files in huge projects emacs anurag Ramdasan
@ 2013-09-27 10:52 ` Sebastien Vauban
  2013-09-27 11:46   ` Tassilo Horn
       [not found]   ` <mailman.2985.1380282382.10748.help-gnu-emacs@gnu.org>
  2013-09-27 15:38 ` Drew Adams
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 11+ messages in thread
From: Sebastien Vauban @ 2013-09-27 10:52 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

anurag Ramdasan wrote:
> I have been using Vim for a while although I would shift to E..macs for
> Org-mode and Slime. When I end up working on a huge project with hundreds or
> even thousands of files, I found the nerdtree vim plugin to be the best thing
> to suit my ways. Also I find dired a little difficult to browse through.
>
> So when I recently gave thoughts to completely moving to emacs, I couldn't find
> anything as good as Nerdtree. I did find dirtree but it didn't seem as easy to
> use as nerdtree. This made me wonder, how do most emacs users navigate through
> huge projects? Is there some common practice or some plugin that I haven't
> heard of yet? Also I use both vim and emacs from the terminal and not the GUI
> client.

I use helm in its simplest form (M-x helm-for-files, bound to f3 in my local
config): then, I just type (part of) the filename, and I get my file opened in
a buffer...

Best regards,
  Seb

-- 
Sebastien Vauban


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: browsing files in huge projects emacs
  2013-09-27 10:52 ` Sebastien Vauban
@ 2013-09-27 11:46   ` Tassilo Horn
       [not found]   ` <mailman.2985.1380282382.10748.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Tassilo Horn @ 2013-09-27 11:46 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: help-gnu-emacs

"Sebastien Vauban" <sva-news@mygooglest.com> writes:

>> I have been using Vim for a while although I would shift to E..macs
>> for Org-mode and Slime. When I end up working on a huge project with
>> hundreds or even thousands of files, I found the nerdtree vim plugin
>> to be the best thing to suit my ways.
>
> I use helm in its simplest form (M-x helm-for-files, bound to f3 in my
> local config): then, I just type (part of) the filename, and I get my
> file opened in a buffer...

I also use helm.  But speedbar provides an interface that's pretty
similar to NERD Tree, so you might want to try that, too.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: browsing files in huge projects emacs
       [not found]   ` <mailman.2985.1380282382.10748.help-gnu-emacs@gnu.org>
@ 2013-09-27 13:50     ` anurag Ramdasan
  0 siblings, 0 replies; 11+ messages in thread
From: anurag Ramdasan @ 2013-09-27 13:50 UTC (permalink / raw)
  To: help-gnu-emacs

On Friday, September 27, 2013 5:16:06 PM UTC+5:30, Tassilo Horn wrote:
> "Sebastien Vauban" <sva-news@mygooglest.com> writes:
> 
> 
> 
> >> I have been using Vim for a while although I would shift to E..macs
> 
> >> for Org-mode and Slime. When I end up working on a huge project with
> 
> >> hundreds or even thousands of files, I found the nerdtree vim plugin
> 
> >> to be the best thing to suit my ways.
> 
> >
> 
> > I use helm in its simplest form (M-x helm-for-files, bound to f3 in my
> 
> > local config): then, I just type (part of) the filename, and I get my
> 
> > file opened in a buffer...
> 
> 
> 
> I also use helm.  But speedbar provides an interface that's pretty
> 
> similar to NERD Tree, so you might want to try that, too.
> 
> 
> 
> Bye,
> 
> Tassilo

Helms looks good. But I liked speedbar more. Set it up with sr-speedbr so that it can just be permanently docked to the left of my emacs and its perfect for me now.

Thanks.
- AR.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: browsing files in huge projects emacs
  2013-09-27 10:48 browsing files in huge projects emacs anurag Ramdasan
  2013-09-27 10:52 ` Sebastien Vauban
@ 2013-09-27 15:38 ` Drew Adams
  2013-09-27 20:08 ` Pascal J. Bourguignon
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Drew Adams @ 2013-09-27 15:38 UTC (permalink / raw)
  To: anurag Ramdasan, help-gnu-emacs

> I end up working on a huge project with hundreds or even thousands
> of files...  I find dired a little difficult to browse through.
> 
> navigate through huge projects ... I use vim and emacs from the
> terminal and not the GUI client.

1. Bookmarks - to directories, for example.  And to Emacs desktops
   (snapshots recording buffers, windows, variables, etc.).

   See Bookmark+ for the latter, and for the former too if you want
   Dired state (markings, subdir insertions etc.) to be recorded &
   restored.

2. `locate-file'.  (Or with Icicles, `icicle-locate' (if you have an OS
   `locate' command) or `icicle-locate-file'.)



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: browsing files in huge projects emacs
  2013-09-27 10:48 browsing files in huge projects emacs anurag Ramdasan
  2013-09-27 10:52 ` Sebastien Vauban
  2013-09-27 15:38 ` Drew Adams
@ 2013-09-27 20:08 ` Pascal J. Bourguignon
  2013-09-27 22:34   ` Emanuel Berg
  2013-09-27 22:30 ` Emanuel Berg
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Pascal J. Bourguignon @ 2013-09-27 20:08 UTC (permalink / raw)
  To: help-gnu-emacs

anurag Ramdasan <aranurag220@gmail.com> writes:

> Hey,
>
> I have been using Vim for a while although I would shift to E..macs
> for Org-mode and Slime. When I end up working on a huge project with
> hundreds or even thousands of files, I found the nerdtree vim plugin
> to be the best thing to suit my ways. Also I find dired a little
> difficult to browse through.
>
> So when I recently gave thoughts to completely moving to emacs, I
> couldn't find anything as good as Nerdtree. I did find dirtree but it
> didn't seem as easy to use as nerdtree. This made me wonder, how do
> most emacs users navigate through huge projects? Is there some common
> practice or some plugin that I haven't heard of yet? Also I use both
> vim and emacs from the terminal and not the GUI client.

There's M-x speedbar RET too.

But honestly, in my projects, I know them my files by name.  So I have a
command set-sources which lets me specify the root directory for my
project, and a command sources-find-file-named which let me open a file by
name (including completion), whatever subdirectory it's in (or presents
a menu if there are several files with the same name).

I never need to "browse" properly.

https://gitorious.org/com-informatimago/emacs/source/b58a0a336b46f3523700931117b409307b13d9b0:pjb-sources.el#L3277
https://gitorious.org/com-informatimago/emacs/source/b58a0a336b46f3523700931117b409307b13d9b0:pjb-sources.el#L3307

(Current version builds a file list in set-sources ; it should be
improved to update it automatically when files change).

-- 
__Pascal Bourguignon__
http://www.informatimago.com/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: browsing files in huge projects emacs
  2013-09-27 10:48 browsing files in huge projects emacs anurag Ramdasan
                   ` (2 preceding siblings ...)
  2013-09-27 20:08 ` Pascal J. Bourguignon
@ 2013-09-27 22:30 ` Emanuel Berg
  2013-09-30  9:42   ` anurag Ramdasan
  2013-09-28  9:25 ` William Xu
  2013-10-11 13:28 ` Alex Bennée
  5 siblings, 1 reply; 11+ messages in thread
From: Emanuel Berg @ 2013-09-27 22:30 UTC (permalink / raw)
  To: help-gnu-emacs

anurag Ramdasan <aranurag220@gmail.com> writes:

> I have been using Vim for a while although I would
> shift to E..macs for Org-mode and Slime. When I end up
> working on a huge project with hundreds or even
> thousands of files, I found the nerdtree vim plugin to
> be the best thing to suit my ways. Also I find dired a
> little difficult to browse through.
>
> So when I recently gave thoughts to completely moving
> to emacs, I couldn't find anything as good as
> Nerdtree. I did find dirtree but it didn't seem as
> easy to use as nerdtree. This made me wonder, how do
> most emacs users navigate through huge projects? Is
> there some common practice or some plugin that I
> haven't heard of yet? Also I use both vim and emacs
> from the terminal and not the GUI client.

This has always been a challenge for me, although I never
worked with as many files as did you. You will get
better answers as to what specific tool to use, but I
thought I'd show some of the things that I setup, that I
have found useful.

This post turned out huge! I'll put it here [1], if you
don't like to digest it all right now.

Although I made a text file of it, I think Elisp mode
would be beneficial as there is so much code, and you
probably want highlight and such to be able to
read/interact with it.

As *always*, any fixes and suggestions are welcome. I
use the stuff below every day, so if anything could be
improved I am very appreciative.

1. Find files

Go to a file that is mentioned - let's say, in a
comment (it requires the ~ notation for your home
directory, and not /home/username/... ). Will prompt for
super user privileges if needed.

(defun goto-file ()
  (interactive)
  (let*((file (thing-at-point 'filename))
        (in-home (string= "~" (car (split-string file "/"))))
        (final-file (if in-home file
                      (format "%s%s" "/sudo::" file) )))
    (find-file final-file) ))

Open a script that you know by name, that is in
~/scripts.

(defun cats (script)
  (interactive "s script: ")
  (find-file (format "%s/scripts/%s" (getenv "HOME") script)) )

2. Buffer menus and some useful shortcuts

In /etc/console-setup/remap.inc

# caps
keycode 58       = U+0111  # caps
shift keycode 58 = U+0113  # S-caps

Get the keycode with the shell tool showkey. (It doesn't
matter what goofy Unicode chars you use.)

Update (for *all* Linux VTs): loadkeys -c -s key_map_file

or, in .zshrc

lkeys () {
   sudo loadkeys --clearcompose --clearstrings
     /etc/console-setup/remap.inc > /dev/null
}

Sometimes it is necessary to delete a cached keymap in
/etc/console-setup. Also, I'm on Debian. I don't know if
those paths are the same for other distros. On
altogether other systems, probably something similar
would still work.

Then, in ~/.emacs (or a file loaded from there), put

(define-key input-decode-map [?\u0114] [M-tab])
(global-set-key (kbd "<M-tab>") 'switch-buffer)

(define-key input-decode-map [?\u0111] [caps])
(global-set-key (kbd "<caps>") 'buffer-menu-files-only)

(define-key input-decode-map [?\u0113] [S-caps])
(global-set-key (kbd "<S-caps>") 'buffer-menu)

(defun switch-buffer ()
  (interactive)
  (switch-to-buffer nil) )

(defun buffer-menu-files-only ()
  (interactive)
  (buffer-menu t) )

Fast keys in the buffer menu that won't require you to
move your hands:

(let ((the-map Buffer-menu-mode-map))
  (define-key the-map (kbd "i") 'previous-line)
  (define-key the-map (kbd "k") 'next-line)
  (define-key the-map (kbd "w") 'kill-this-buffer)
  )

3. Some integration with bash/zsh, in another Linux VT:

Again, in /etc/console-setup/remap.inc, setup
minimal/close shortcuts:

# J - Emacs
alt keycode 36       = Console_1
ctrll alt keycode 36 = Console_1
# L - tmux and more
alt keycode 38       = Incr_Console
ctrll alt keycode 38 = Incr_Console

Then the script

#!/bin/zsh

DIR=`pwd`
LS_PATH="${DIR/$HOME/~}/`\ls -dl $1 | tr -s ' ' | cut -d' ' -f 9`"
echo -n $LS_PATH | xclip -d ":0" -selection clipboard -in
echo "(find-file \"$LS_PATH\")" > ~/.lsp_file

Usage: lsp filename.extension

Get back to Emacs by hitting M-j, then find the file
with the same command (M-x lsp RET, or assign a
shortcut).

(defun lsp ()
  (interactive)
  (load-file "~/.lsp_file") )

Note: Wouldn't it be cool to get back to Emacs
immediately on lsp? The shell tool chvt could do it from
a basic Linux VT, but I run tmux on top of them, so I
get "Couldn't get a file descriptor referring to the
console".

4. Kill and yank filenames and their paths

(defun kill-name ()
  (interactive)
  (let ((name (buffer-name)))
    (message (format " Killed %s" name))
    (kill-new name) ))

(defun kill-path ()
  (interactive)
  (require 'cl)
  (labels ((print-kill-path (killed)
             (message (format "killed %s" killed))
             (kill-new killed) )
           (print-kill-home-path (killed)
             (print-kill-path
              (format "~%s" (substring file-name home-prefix-len)) )))
    (let*((file-name (buffer-file-name))
          (file-name-len (length file-name))
          (home-prefix (getenv "HOME"))
          (home-prefix-len (length home-prefix))
          (sudo-prefix "/sudo:")
          (sudo-prefix-len (length sudo-prefix))
          (root-prefix
           (format "%sroot@%s:" sudo-prefix (message-make-domain)) )
          (root-prefix-len (length root-prefix)) )
      (if (< file-name-len sudo-prefix-len)
          (print-kill-home-path file-name)
        (if (string= (substring file-name 0 sudo-prefix-len)
                     sudo-prefix)
            (let ((stripped-file-name
                   (substring file-name root-prefix-len) ))
              (print-kill-path stripped-file-name) )
          (progn
            (if (string= (substring file-name 0 home-prefix-len)
                         home-prefix)
                (print-kill-home-path file-name)
              (print-kill-path file-name) )))))))

(defun yank-path ()
  (interactive)
  (kill-path)
  (yank) )

5. Update file

 (defun refresh-file ()
  (interactive)
  (revert-buffer
    t t nil) ; ignore-auto(-save), noconfirm, preserve-modes
  (message "Up to date.") )

6. Jump between configuration files

(global-set-key (kbd "C-j") 'jump-to-register)

(set-register ?a (cons 'file "/sudo::/etc/apt/sources.list"))
(set-register ?b (cons 'file "~/News/KILL"))
(set-register ?C (cons 'file "/sudo::/etc/default/console-setup"))
(set-register ?c (cons 'file "~/.irssi/config"))
(set-register ?d (cons 'file "~/.emacs-dired"))
; etc.

7. Make a script executable, from the buffer in which you edit it

(defun make-executable ()
  (interactive)
  (shell-command (concat "chmod +x " buffer-file-name)) )

8. Edit the current file as super user

(defun su-edit ()
  (interactive)
  (let ((window-start (window-start))
        (point        (point))
        (mark (if mark-active (region-beginning) nil)) )
    (find-alternate-file (format "/sudo::%s" (buffer-file-name)))
    (if mark (set-mark mark))
    (goto-char point)
    (set-window-start nil window-start) ; nil - the selected window
    ))

9. Dired

Shorter and closer, and thus faster and more ergonomic,
shortcuts:

(defun scroll-up-other-window ()
  (interactive)
  (scroll-other-window-down 1) )
(defun scroll-down-other-window ()
  (interactive)
  (scroll-other-window 1) )

(setq dired-deletion-confirmer '(lambda (x) t))

(let ((map dired-mode-map))
  (define-key map (kbd "C-d") 'dired-do-delete)
  ;; navigate
  (define-key map (kbd "w") 'dired-up-directory)
  (define-key map (kbd "s") 'dired-find-file-other-window)
  (define-key map (kbd "i") 'dired-previous-line)
  (define-key map (kbd "k") 'dired-next-line)
  ;; scroll
  (define-key map (kbd "d") 'scroll-up-other-window)
  (define-key map (kbd "f") 'scroll-down-other-window) )

10. Get a new prefix key to get more small and close
    shortcuts, that can be setup to reach files,
    navigate buffers, etc.

(defun init-C-o-prefix ()
  (interactive)
  (define-prefix-command 'C-o-prefix)
  (global-set-key "\C-o" 'C-o-prefix)
  (init-C-o-keys) )
(add-hook 'after-init-hook 'init-C-o-prefix)

(defun init-C-o-keys ()
  (interactive)
  (let ((the-map (current-global-map)))
    (define-key the-map "\C-oo" 'split-window-vertically-shift)
    ; etc
    ))

(defun split-window-vertically-shift ()
  (interactive)
  (split-window-vertically)
  (other-window 1) )

11. Split windows (sometimes)

The way I use Emacs, in a Linux VT with a huge font,
more than two windows is seldom useful. (I use a
projector, that's why I can't have it any other way.)
So, I setup M-o to split the window, only - if it is
already split - don't split, jump. (Also, M-p will
maximize the current window.)

(defun other-window-or-split ()
  (interactive)
  (if (= 1 (count-windows)) (split-window-vertically))
  (other-window 1) )

(let ((the-map (current-global-map)))
  (define-key the-map "\M-o" 'other-window-or-split)
  (define-key the-map "\M-p" 'delete-other-windows) )

12. Jumping to files mentioned in the man pages

(let ((the-map Man-mode-map))
  (define-key the-map (kbd "M-RET") 'goto-file) ; mentioned above
  (define-key the-map (kbd "w") 'kill-this-buffer)
  ; etc.
  )

[1] http://user.it.uu.se/~embe8573/emacs_files.txt

-- 
Emanuel Berg - programmer (hire me! CV below)
computer projects: http://user.it.uu.se/~embe8573
internet activity: http://home.student.uu.se/embe8573


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: browsing files in huge projects emacs
  2013-09-27 20:08 ` Pascal J. Bourguignon
@ 2013-09-27 22:34   ` Emanuel Berg
  0 siblings, 0 replies; 11+ messages in thread
From: Emanuel Berg @ 2013-09-27 22:34 UTC (permalink / raw)
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com> writes:

> There's M-x speedbar RET too.
>
> But honestly, in my projects, I know them my files by
> name.  So I have a command set-sources which lets me
> specify the root directory for my project, ...

Thanks for sharing, that looks interesting because I
always make an effort to keep file names short, probably
your idea would be ideal for me. I'll get back to you
when I've tried it.

-- 
Emanuel Berg - programmer (hire me! CV below)
computer projects: http://user.it.uu.se/~embe8573
internet activity: http://home.student.uu.se/embe8573


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: browsing files in huge projects emacs
  2013-09-27 10:48 browsing files in huge projects emacs anurag Ramdasan
                   ` (3 preceding siblings ...)
  2013-09-27 22:30 ` Emanuel Berg
@ 2013-09-28  9:25 ` William Xu
  2013-10-11 13:28 ` Alex Bennée
  5 siblings, 0 replies; 11+ messages in thread
From: William Xu @ 2013-09-28  9:25 UTC (permalink / raw)
  To: help-gnu-emacs

anurag Ramdasan <aranurag220@gmail.com> writes:

> Hey,
>
> I have been using Vim for a while although I would shift to E..macs for Org-mode
> and Slime. When I end up working on a huge project with hundreds or even
> thousands of files, I found the nerdtree vim plugin to be the best thing to suit
> my ways. Also I find dired a little difficult to browse through.
>
> So when I recently gave thoughts to completely moving to emacs, I couldn't find
> anything as good as Nerdtree. I did find dirtree but it didn't seem as easy to
> use as nerdtree. This made me wonder, how do most emacs users navigate through
> huge projects? Is there some common practice or some plugin that I haven't heard
> of yet? Also I use both vim and emacs from the terminal and not the GUI client.

I use `global' to generate the index, then use gtags.el in emacs.

-- 
William

http://xwl.appspot.com




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: browsing files in huge projects emacs
  2013-09-27 22:30 ` Emanuel Berg
@ 2013-09-30  9:42   ` anurag Ramdasan
  0 siblings, 0 replies; 11+ messages in thread
From: anurag Ramdasan @ 2013-09-30  9:42 UTC (permalink / raw)
  To: help-gnu-emacs

On Saturday, September 28, 2013 4:00:05 AM UTC+5:30, Emanuel Berg wrote:
> anurag Ramdasan <aranurag220@gmail.com> writes:
> 
> 
> 
> > I have been using Vim for a while although I would
> 
> > shift to E..macs for Org-mode and Slime. When I end up
> 
> > working on a huge project with hundreds or even
> 
> > thousands of files, I found the nerdtree vim plugin to
> 
> > be the best thing to suit my ways. Also I find dired a
> 
> > little difficult to browse through.
> 
> >
> 
> > So when I recently gave thoughts to completely moving
> 
> > to emacs, I couldn't find anything as good as
> 
> > Nerdtree. I did find dirtree but it didn't seem as
> 
> > easy to use as nerdtree. This made me wonder, how do
> 
> > most emacs users navigate through huge projects? Is
> 
> > there some common practice or some plugin that I
> 
> > haven't heard of yet? Also I use both vim and emacs
> 
> > from the terminal and not the GUI client.
> 
> 
> 
> This has always been a challenge for me, although I never
> 
> worked with as many files as did you. You will get
> 
> better answers as to what specific tool to use, but I
> 
> thought I'd show some of the things that I setup, that I
> 
> have found useful.
> 
> 
> 
> This post turned out huge! I'll put it here [1], if you
> 
> don't like to digest it all right now.
> 
> 
> 
> Although I made a text file of it, I think Elisp mode
> 
> would be beneficial as there is so much code, and you
> 
> probably want highlight and such to be able to
> 
> read/interact with it.
> 
> 
> 
> As *always*, any fixes and suggestions are welcome. I
> 
> use the stuff below every day, so if anything could be
> 
> improved I am very appreciative.
> 
> 
> 
> 1. Find files
> 
> 
> 
> Go to a file that is mentioned - let's say, in a
> 
> comment (it requires the ~ notation for your home
> 
> directory, and not /home/username/... ). Will prompt for
> 
> super user privileges if needed.
> 
> 
> 
> (defun goto-file ()
> 
>   (interactive)
> 
>   (let*((file (thing-at-point 'filename))
> 
>         (in-home (string= "~" (car (split-string file "/"))))
> 
>         (final-file (if in-home file
> 
>                       (format "%s%s" "/sudo::" file) )))
> 
>     (find-file final-file) ))
> 
> 
> 
> Open a script that you know by name, that is in
> 
> ~/scripts.
> 
> 
> 
> (defun cats (script)
> 
>   (interactive "s script: ")
> 
>   (find-file (format "%s/scripts/%s" (getenv "HOME") script)) )
> 
> 
> 
> 2. Buffer menus and some useful shortcuts
> 
> 
> 
> In /etc/console-setup/remap.inc
> 
> 
> 
> # caps
> 
> keycode 58       = U+0111  # caps
> 
> shift keycode 58 = U+0113  # S-caps
> 
> 
> 
> Get the keycode with the shell tool showkey. (It doesn't
> 
> matter what goofy Unicode chars you use.)
> 
> 
> 
> Update (for *all* Linux VTs): loadkeys -c -s key_map_file
> 
> 
> 
> or, in .zshrc
> 
> 
> 
> lkeys () {
> 
>    sudo loadkeys --clearcompose --clearstrings
> 
>      /etc/console-setup/remap.inc > /dev/null
> 
> }
> 
> 
> 
> Sometimes it is necessary to delete a cached keymap in
> 
> /etc/console-setup. Also, I'm on Debian. I don't know if
> 
> those paths are the same for other distros. On
> 
> altogether other systems, probably something similar
> 
> would still work.
> 
> 
> 
> Then, in ~/.emacs (or a file loaded from there), put
> 
> 
> 
> (define-key input-decode-map [?\u0114] [M-tab])
> 
> (global-set-key (kbd "<M-tab>") 'switch-buffer)
> 
> 
> 
> (define-key input-decode-map [?\u0111] [caps])
> 
> (global-set-key (kbd "<caps>") 'buffer-menu-files-only)
> 
> 
> 
> (define-key input-decode-map [?\u0113] [S-caps])
> 
> (global-set-key (kbd "<S-caps>") 'buffer-menu)
> 
> 
> 
> (defun switch-buffer ()
> 
>   (interactive)
> 
>   (switch-to-buffer nil) )
> 
> 
> 
> (defun buffer-menu-files-only ()
> 
>   (interactive)
> 
>   (buffer-menu t) )
> 
> 
> 
> Fast keys in the buffer menu that won't require you to
> 
> move your hands:
> 
> 
> 
> (let ((the-map Buffer-menu-mode-map))
> 
>   (define-key the-map (kbd "i") 'previous-line)
> 
>   (define-key the-map (kbd "k") 'next-line)
> 
>   (define-key the-map (kbd "w") 'kill-this-buffer)
> 
>   )
> 
> 
> 
> 3. Some integration with bash/zsh, in another Linux VT:
> 
> 
> 
> Again, in /etc/console-setup/remap.inc, setup
> 
> minimal/close shortcuts:
> 
> 
> 
> # J - Emacs
> 
> alt keycode 36       = Console_1
> 
> ctrll alt keycode 36 = Console_1
> 
> # L - tmux and more
> 
> alt keycode 38       = Incr_Console
> 
> ctrll alt keycode 38 = Incr_Console
> 
> 
> 
> Then the script
> 
> 
> 
> #!/bin/zsh
> 
> 
> 
> DIR=`pwd`
> 
> LS_PATH="${DIR/$HOME/~}/`\ls -dl $1 | tr -s ' ' | cut -d' ' -f 9`"
> 
> echo -n $LS_PATH | xclip -d ":0" -selection clipboard -in
> 
> echo "(find-file \"$LS_PATH\")" > ~/.lsp_file
> 
> 
> 
> Usage: lsp filename.extension
> 
> 
> 
> Get back to Emacs by hitting M-j, then find the file
> 
> with the same command (M-x lsp RET, or assign a
> 
> shortcut).
> 
> 
> 
> (defun lsp ()
> 
>   (interactive)
> 
>   (load-file "~/.lsp_file") )
> 
> 
> 
> Note: Wouldn't it be cool to get back to Emacs
> 
> immediately on lsp? The shell tool chvt could do it from
> 
> a basic Linux VT, but I run tmux on top of them, so I
> 
> get "Couldn't get a file descriptor referring to the
> 
> console".
> 
> 
> 
> 4. Kill and yank filenames and their paths
> 
> 
> 
> (defun kill-name ()
> 
>   (interactive)
> 
>   (let ((name (buffer-name)))
> 
>     (message (format " Killed %s" name))
> 
>     (kill-new name) ))
> 
> 
> 
> (defun kill-path ()
> 
>   (interactive)
> 
>   (require 'cl)
> 
>   (labels ((print-kill-path (killed)
> 
>              (message (format "killed %s" killed))
> 
>              (kill-new killed) )
> 
>            (print-kill-home-path (killed)
> 
>              (print-kill-path
> 
>               (format "~%s" (substring file-name home-prefix-len)) )))
> 
>     (let*((file-name (buffer-file-name))
> 
>           (file-name-len (length file-name))
> 
>           (home-prefix (getenv "HOME"))
> 
>           (home-prefix-len (length home-prefix))
> 
>           (sudo-prefix "/sudo:")
> 
>           (sudo-prefix-len (length sudo-prefix))
> 
>           (root-prefix
> 
>            (format "%sroot@%s:" sudo-prefix (message-make-domain)) )
> 
>           (root-prefix-len (length root-prefix)) )
> 
>       (if (< file-name-len sudo-prefix-len)
> 
>           (print-kill-home-path file-name)
> 
>         (if (string= (substring file-name 0 sudo-prefix-len)
> 
>                      sudo-prefix)
> 
>             (let ((stripped-file-name
> 
>                    (substring file-name root-prefix-len) ))
> 
>               (print-kill-path stripped-file-name) )
> 
>           (progn
> 
>             (if (string= (substring file-name 0 home-prefix-len)
> 
>                          home-prefix)
> 
>                 (print-kill-home-path file-name)
> 
>               (print-kill-path file-name) )))))))
> 
> 
> 
> (defun yank-path ()
> 
>   (interactive)
> 
>   (kill-path)
> 
>   (yank) )
> 
> 
> 
> 5. Update file
> 
> 
> 
>  (defun refresh-file ()
> 
>   (interactive)
> 
>   (revert-buffer
> 
>     t t nil) ; ignore-auto(-save), noconfirm, preserve-modes
> 
>   (message "Up to date.") )
> 
> 
> 
> 6. Jump between configuration files
> 
> 
> 
> (global-set-key (kbd "C-j") 'jump-to-register)
> 
> 
> 
> (set-register ?a (cons 'file "/sudo::/etc/apt/sources.list"))
> 
> (set-register ?b (cons 'file "~/News/KILL"))
> 
> (set-register ?C (cons 'file "/sudo::/etc/default/console-setup"))
> 
> (set-register ?c (cons 'file "~/.irssi/config"))
> 
> (set-register ?d (cons 'file "~/.emacs-dired"))
> 
> ; etc.
> 
> 
> 
> 7. Make a script executable, from the buffer in which you edit it
> 
> 
> 
> (defun make-executable ()
> 
>   (interactive)
> 
>   (shell-command (concat "chmod +x " buffer-file-name)) )
> 
> 
> 
> 8. Edit the current file as super user
> 
> 
> 
> (defun su-edit ()
> 
>   (interactive)
> 
>   (let ((window-start (window-start))
> 
>         (point        (point))
> 
>         (mark (if mark-active (region-beginning) nil)) )
> 
>     (find-alternate-file (format "/sudo::%s" (buffer-file-name)))
> 
>     (if mark (set-mark mark))
> 
>     (goto-char point)
> 
>     (set-window-start nil window-start) ; nil - the selected window
> 
>     ))
> 
> 
> 
> 9. Dired
> 
> 
> 
> Shorter and closer, and thus faster and more ergonomic,
> 
> shortcuts:
> 
> 
> 
> (defun scroll-up-other-window ()
> 
>   (interactive)
> 
>   (scroll-other-window-down 1) )
> 
> (defun scroll-down-other-window ()
> 
>   (interactive)
> 
>   (scroll-other-window 1) )
> 
> 
> 
> (setq dired-deletion-confirmer '(lambda (x) t))
> 
> 
> 
> (let ((map dired-mode-map))
> 
>   (define-key map (kbd "C-d") 'dired-do-delete)
> 
>   ;; navigate
> 
>   (define-key map (kbd "w") 'dired-up-directory)
> 
>   (define-key map (kbd "s") 'dired-find-file-other-window)
> 
>   (define-key map (kbd "i") 'dired-previous-line)
> 
>   (define-key map (kbd "k") 'dired-next-line)
> 
>   ;; scroll
> 
>   (define-key map (kbd "d") 'scroll-up-other-window)
> 
>   (define-key map (kbd "f") 'scroll-down-other-window) )
> 
> 
> 
> 10. Get a new prefix key to get more small and close
> 
>     shortcuts, that can be setup to reach files,
> 
>     navigate buffers, etc.
> 
> 
> 
> (defun init-C-o-prefix ()
> 
>   (interactive)
> 
>   (define-prefix-command 'C-o-prefix)
> 
>   (global-set-key "\C-o" 'C-o-prefix)
> 
>   (init-C-o-keys) )
> 
> (add-hook 'after-init-hook 'init-C-o-prefix)
> 
> 
> 
> (defun init-C-o-keys ()
> 
>   (interactive)
> 
>   (let ((the-map (current-global-map)))
> 
>     (define-key the-map "\C-oo" 'split-window-vertically-shift)
> 
>     ; etc
> 
>     ))
> 
> 
> 
> (defun split-window-vertically-shift ()
> 
>   (interactive)
> 
>   (split-window-vertically)
> 
>   (other-window 1) )
> 
> 
> 
> 11. Split windows (sometimes)
> 
> 
> 
> The way I use Emacs, in a Linux VT with a huge font,
> 
> more than two windows is seldom useful. (I use a
> 
> projector, that's why I can't have it any other way.)
> 
> So, I setup M-o to split the window, only - if it is
> 
> already split - don't split, jump. (Also, M-p will
> 
> maximize the current window.)
> 
> 
> 
> (defun other-window-or-split ()
> 
>   (interactive)
> 
>   (if (= 1 (count-windows)) (split-window-vertically))
> 
>   (other-window 1) )
> 
> 
> 
> (let ((the-map (current-global-map)))
> 
>   (define-key the-map "\M-o" 'other-window-or-split)
> 
>   (define-key the-map "\M-p" 'delete-other-windows) )
> 
> 
> 
> 12. Jumping to files mentioned in the man pages
> 
> 
> 
> (let ((the-map Man-mode-map))
> 
>   (define-key the-map (kbd "M-RET") 'goto-file) ; mentioned above
> 
>   (define-key the-map (kbd "w") 'kill-this-buffer)
> 
>   ; etc.
> 
>   )
> 
> 
> 
> [1] http://user.it.uu.se/~embe8573/emacs_files.txt
> 
> 
> 
> -- 
> 
> Emanuel Berg - programmer (hire me! CV below)
> 
> computer projects: http://user.it.uu.se/~embe8573
> 
> internet activity: http://home.student.uu.se/embe8573

That looks great. Will definitely try it out. Thanks.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: browsing files in huge projects emacs
  2013-09-27 10:48 browsing files in huge projects emacs anurag Ramdasan
                   ` (4 preceding siblings ...)
  2013-09-28  9:25 ` William Xu
@ 2013-10-11 13:28 ` Alex Bennée
  5 siblings, 0 replies; 11+ messages in thread
From: Alex Bennée @ 2013-10-11 13:28 UTC (permalink / raw)
  To: anurag Ramdasan; +Cc: help-gnu-emacs


aranurag220@gmail.com writes:

> Hey,
>
> I have been using Vim for a while although I would shift to E..macs
> for Org-mode and Slime. When I end up working on a huge project with
> hundreds or even thousands of files, I found the nerdtree vim plugin
> to be the best thing to suit my ways. Also I find dired a little
> difficult to browse through.

I use lusty-explorer which I believe is a port of a vim plugin. It does
lazy/fuzzy completion so generally by navigation is
letter-letter->tab->letter->tab->letter return.

As my project tree is in grep I also use helm-git-grep when searching
for things that I don't know where they are defined. I have another
shortcut to ack-and-a-half that searches down from my current directory.
With all those I find navigating around pretty easy.

-- 
Alex Bennée



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-10-11 13:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-27 10:48 browsing files in huge projects emacs anurag Ramdasan
2013-09-27 10:52 ` Sebastien Vauban
2013-09-27 11:46   ` Tassilo Horn
     [not found]   ` <mailman.2985.1380282382.10748.help-gnu-emacs@gnu.org>
2013-09-27 13:50     ` anurag Ramdasan
2013-09-27 15:38 ` Drew Adams
2013-09-27 20:08 ` Pascal J. Bourguignon
2013-09-27 22:34   ` Emanuel Berg
2013-09-27 22:30 ` Emanuel Berg
2013-09-30  9:42   ` anurag Ramdasan
2013-09-28  9:25 ` William Xu
2013-10-11 13:28 ` Alex Bennée

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.