over a year ago. Comments and testing from gkoehler@. Thanks to both.
Also, some modifications from me.
-/* $OpenBSD: def.h,v 1.171 2021/03/25 12:46:11 lum Exp $ */
+/* $OpenBSD: def.h,v 1.172 2021/04/20 10:02:50 lum Exp $ */
/* This file is in the public domain. */
/* dired.c */
struct buffer *dired_(char *);
+int dired_jump(int, int);
int do_dired(char *);
/* file.c X */
-/* $OpenBSD: dired.c,v 1.98 2021/03/05 16:16:53 lum Exp $ */
+/* $OpenBSD: dired.c,v 1.99 2021/04/20 10:02:50 lum Exp $ */
/* This file is in the public domain. */
static int d_filevisitalt(int, int);
static int d_gotofile(int, int);
static void reaper(int);
+static int gotofile(char*);
static struct buffer *refreshbuffer(struct buffer *);
static int createlist(struct buffer *);
static void redelete(struct buffer *);
return (ret);
}
+int
+dired_jump(int f, int n)
+{
+ struct buffer *bp;
+ const char *modename;
+ char dname[NFILEN], *fname;
+ int ret, i;
+
+ /*
+ * We use fundamental mode in dired, so just check we aren't in
+ * dired mode for this specific function. Seems like a corner
+ * case at the moment.
+ */
+ for (i = 0; i <= curbp->b_nmodes; i++) {
+ modename = curbp->b_modes[i]->p_name;
+ if (strncmp(modename, "dired", 5) == 0)
+ return (dobeep_msg("In dired mode already"));
+ }
+
+ if (getbufcwd(dname, sizeof(dname)) != TRUE)
+ return (FALSE);
+
+ fname = curbp->b_fname;
+
+ if ((bp = dired_(dname)) == NULL)
+ return (FALSE);
+ curbp = bp;
+
+ ret = showbuffer(bp, curwp, WFFULL | WFMODE);
+ if (ret != TRUE)
+ return ret;
+
+ fname = adjustname(fname, TRUE);
+ if (fname != NULL)
+ gotofile(fname);
+
+ return (TRUE);
+}
+
int
d_gotofile(int f, int n)
{
- struct line *lp, *nlp;
size_t lenfpath;
- char fpath[NFILEN], fname[NFILEN];
- char *p, *fpth, *fnp = NULL;
- int tmp;
+ char fpath[NFILEN];
+ char *fpth, *fnp = NULL;
if (getbufcwd(fpath, sizeof(fpath)) != TRUE)
fpath[0] = '\0';
ewprintf("No file to find"); /* Current directory given so */
return (TRUE); /* return at present location. */
}
+ return gotofile(fpth);
+}
+
+int
+gotofile(char *fpth)
+{
+ struct line *lp, *nlp;
+ char fname[NFILEN];
+ char *p;
+ int tmp;
+
(void)xbasename(fname, fpth, NFILEN);
- curbp = curwp->w_bufp;
tmp = 0;
for (lp = bfirstlp(curbp); lp != curbp->b_headp; lp = nlp) {
tmp++;
-/* $OpenBSD: funmap.c,v 1.60 2021/03/23 18:33:05 lum Exp $ */
+/* $OpenBSD: funmap.c,v 1.61 2021/04/20 10:02:50 lum Exp $ */
/* This file is in the public domain */
{desckey, "describe-key-briefly", 1},
{diffbuffer, "diff-buffer-with-file", 0},
{digit_argument, "digit-argument", 1},
+ {dired_jump, "dired-jump", 1},
{lowerregion, "downcase-region", 0},
{lowerword, "downcase-word", 1},
{showversion, "emacs-version", 0},
-/* $OpenBSD: keymap.c,v 1.58 2015/12/29 19:44:32 lum Exp $ */
+/* $OpenBSD: keymap.c,v 1.59 2021/04/20 10:02:50 lum Exp $ */
/* This file is in the public domain. */
ctrlg /* ^G */
};
-static PF cXcL[] = {
+static PF cXcJ[] = {
+ dired_jump, /* ^J */
+ rescan, /* ^K */
lowerregion, /* ^L */
rescan, /* ^M */
rescan, /* ^N */
CCHR('B'), CCHR('G'), cXcB, NULL
},
{
- CCHR('L'), CCHR('X'), cXcL, NULL
+ CCHR('J'), CCHR('X'), cXcJ, NULL
},
{
'(', ')', cXlp, NULL
-.\" $OpenBSD: mg.1,v 1.122 2021/03/26 15:02:10 lum Exp $
+.\" $OpenBSD: mg.1,v 1.123 2021/04/20 10:02:50 lum Exp $
.\" This file is in the public domain.
.\"
-.Dd $Mdocdate: March 26 2021 $
+.Dd $Mdocdate: April 20 2021 $
.Dt MG 1
.Os
.Sh NAME
save-buffers-kill-emacs
.It C-x C-f
find-file
+.It C-x C-j
+dired-jump
.It C-x C-g
keyboard-quit
.It C-x C-l
View the differences between buffer and its associated file.
.It digit-argument
Process a numerical argument for keyboard-invoked functions.
+.It dired-jump
+Open a dired buffer containing the current buffer's directory location.
.It downcase-region
Set all characters in the region to lower case.
.It downcase-word