The man page has an error... it should read: .It q quit-window
----- Forwarded message from Mark Lumsden <m...@showcomplex.com> ----- Date: Sat, 1 Jun 2013 15:05:16 +0000 From: Mark Lumsden <m...@showcomplex.com> To: tech@openbsd.org Subject: mg(1) 'q' for quit-window in dired mode User-Agent: Mutt/1.5.21 (2010-09-15) This diff adds the key binding 'q' and function 'quit-window' to mg's dired mode. Comments/oks? mark Index: buffer.c =================================================================== RCS file: /cvs/src/usr.bin/mg/buffer.c,v retrieving revision 1.90 diff -u -p -r1.90 buffer.c --- buffer.c 17 Feb 2013 10:30:26 -0000 1.90 +++ buffer.c 1 Jun 2013 15:03:07 -0000 @@ -124,10 +124,10 @@ poptobuffer(int f, int n) /* * Dispose of a buffer, by name. - * Ask for the name. Look it up (don't get too - * upset if it isn't there at all!). Clear the buffer (ask + * Ask for the name (unless called by dired mode). Look it up (don't + * get too upset if it isn't there at all!). Clear the buffer (ask * if the buffer has been changed). Then free the header - * line and the buffer header. Bound to "C-X k". + * line and the buffer header. Bound to "C-x k". */ /* ARGSUSED */ int @@ -136,7 +136,9 @@ killbuffer_cmd(int f, int n) struct buffer *bp; char bufn[NBUFN], *bufp; - if ((bufp = eread("Kill buffer: (default %s) ", bufn, NBUFN, + if (f & FFRAND) /* dired mode 'q' */ + bp = curbp; + else if ((bufp = eread("Kill buffer: (default %s) ", bufn, NBUFN, EFNUL | EFNEW | EFBUF, curbp->b_bname)) == NULL) return (ABORT); else if (bufp[0] == '\0') Index: dired.c =================================================================== RCS file: /cvs/src/usr.bin/mg/dired.c,v retrieving revision 1.59 diff -u -p -r1.59 dired.c --- dired.c 30 May 2013 17:43:43 -0000 1.59 +++ dired.c 1 Jun 2013 15:03:07 -0000 @@ -44,6 +44,7 @@ static int d_forwpage(int, int); static int d_backpage(int, int); static int d_forwline(int, int); static int d_backline(int, int); +static int d_killbuffer_cmd(int, int); static void reaper(int); static struct buffer *refreshbuffer(struct buffer *); @@ -109,7 +110,7 @@ static PF diredn[] = { d_forwline, /* n */ d_ffotherwindow, /* o */ d_backline, /* p */ - rescan, /* q */ + d_killbuffer_cmd, /* q */ d_rename, /* r */ rescan, /* s */ rescan, /* t */ @@ -197,6 +198,7 @@ dired_init(void) funmap_add(d_backpage, "dired-scroll-down"); funmap_add(d_forwpage, "dired-scroll-up"); funmap_add(d_undel, "dired-unflag"); + funmap_add(d_killbuffer_cmd, "quit-window"); maps_add((KEYMAP *)&diredmap, "dired"); dobindkey(fundamental_map, "dired", "^Xd"); } @@ -640,6 +642,13 @@ d_create_directory(int f, int n) return (FALSE); return (showbuffer(bp, curwp, WFFULL | WFMODE)); +} + +/* ARGSUSED */ +int +d_killbuffer_cmd(int f, int n) +{ + return(killbuffer_cmd(FFRAND, 0)); } struct buffer * Index: mg.1 =================================================================== RCS file: /cvs/src/usr.bin/mg/mg.1,v retrieving revision 1.80 diff -u -p -r1.80 mg.1 --- mg.1 1 Jun 2013 14:47:07 -0000 1.80 +++ mg.1 1 Jun 2013 15:03:07 -0000 @@ -946,6 +946,8 @@ dired-next-line dired-find-file-other-window .It p dired-previous-line +.It q +dired-previous-line .It r dired-rename-file .It u @@ -995,6 +997,8 @@ Scroll down the dired buffer. Scroll up the dired buffer. .It dired-unflag Remove the deletion flag for the file on the current line. +.It quit-window +Closes the current dired buffer. .El .Sh CONFIGURATION FILES There are two configuration files, ----- End forwarded message -----