home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / emacs / sources / 564 < prev    next >
Encoding:
Text File  |  1992-07-29  |  38.1 KB  |  1,168 lines

  1. Newsgroups: gnu.emacs.sources
  2. Path: sparky!uunet!cis.ohio-state.edu!d0sb10.fnal.gov!SNYDER
  3. From: SNYDER@d0sb10.fnal.gov (scott snyder)
  4. Subject: better subprocess support for vms emacs (3/4)
  5. Message-ID: <920730000116.28a0007c@D0SB10.FNAL.GOV>
  6. Sender: daemon@cis.ohio-state.edu
  7. Organization: Source only  Discussion and requests in gnu.emacs.help.
  8. Distribution: gnu
  9. Date: Wed, 29 Jul 1992 19:01:16 GMT
  10. Lines: 1156
  11.  
  12. -+-+-+-+-+-+-+-+ START OF PART 3 -+-+-+-+-+-+-+-+
  13. V 1992
  14. X***************
  15. X*** 56,59 ****
  16. X--- 56,61 ----
  17. X  sys_errlist,-
  18. X  sys_nerr,-
  19. X  environ
  20. X+ ! if you don't have multinet, comment out the following line.
  21. X+ multinet:multinet_socket_library/share
  22. X  sys$library:vaxcrtl/library
  23. X*** vmsfns.c`09Tue Feb 25 11:59:28 1992
  24. X--- sb12:`5Bscratch.snyder.gnu.emacs-18_58.src`5Dvmsfns.c`09Mon May 18 22:52
  25. V:08 1992
  26. X***************
  27. X*** 188,208 ****
  28. X  static void write_to_mbx ();`09/* Writes message to string */
  29. X  static void start_mbx_input ();`09/* Queues I/O request to mailbox */
  30. X `20
  31. X- static int input_mbx_chan = 0;`09/* Channel to read subprocess input on */
  32. X- static char input_mbx_name`5B20`5D;
  33. X- `09`09`09`09/* Storage for mailbox device name */
  34. X- static struct dsc$descriptor_s input_mbx_dsc;
  35. X- `09`09`09`09/* Descriptor for mailbox device name */
  36. X- static struct process_list * process_list = 0;
  37. X- `09`09`09`09/* Linked list of subprocesses */
  38. X- static char mbx_buffer`5BMSGSIZE`5D;
  39. X- `09`09`09`09/* Buffer to read from subprocesses */
  40. X- static struct mbx_iosb input_iosb;
  41. X- `09`09`09`09/* IO status block for mailbox reads */
  42. X-`20
  43. X- int have_process_input,`09`09/* Non-zero iff subprocess input pending */
  44. X-     process_exited;`09`09/* Non-zero iff suprocess exit pending */
  45. X-`20
  46. X  /* List of privilege names and mask offsets */
  47. X  static struct privilege_list priv_list`5B`5D = `7B
  48. X `20
  49. X--- 188,193 ----
  50. X***************
  51. X*** 277,591 ****
  52. X      `7B "PROCLIST",`09vms_proclist `7D,`09/* Returns list of all PIDs on s
  53. Vystem */
  54. X      `7D;
  55. X    `20
  56. X- Lisp_Object Qdefault_subproc_input_handler;
  57. X-`20
  58. X- extern int process_ef;`09`09/* Event flag for subprocess operations */
  59. X-`20
  60. X- DEFUN ("default-subprocess-input-handler",
  61. X-   Fdefault_subproc_input_handler, Sdefault_subproc_input_handler,
  62. X-   2, 2, 0,
  63. X-   "Default input handler for input from spawned subprocesses.")
  64. X-   (name, input)
  65. X-      Lisp_Object name, input;
  66. X- `7B
  67. X-   /* Just insert in current buffer */
  68. X-   insert (XSTRING (input)->data, XSTRING (input)->size);
  69. X-   insert ("\n", 1);
  70. X- `7D
  71. X-`20
  72. X- DEFUN ("spawn-subprocess", Fspawn_subprocess, Sspawn_subprocess, 1, 3, 0,
  73. X-   "Spawns an asynchronous VMS suprocess for command processing.")
  74. X-   (name, input_handler, exit_handler)
  75. X-      Lisp_Object name, input_handler, exit_handler;
  76. X- `7B
  77. X-   int status;
  78. X-   char output_mbx_name`5B20`5D;
  79. X-   struct dsc$descriptor_s output_mbx_dsc;
  80. X-   struct process_list *ptr, *p, *prev;
  81. X-   static int dummy = CLI$M_NOWAIT;
  82. X-`20
  83. X-   CHECK_NUMBER (name, 0);
  84. X-   if (! input_mbx_chan)
  85. X-     `7B
  86. X-       if (! create_mbx (&input_mbx_dsc, input_mbx_name, &input_mbx_chan, 1
  87. V))
  88. X- `09return Qnil;
  89. X-       start_mbx_input ();
  90. X-     `7D
  91. X-   ptr = 0;
  92. X-   prev = 0;
  93. X-   while (ptr)
  94. X-     `7B
  95. X-       struct process_list *next = ptr->next;
  96. X-       if (ptr->name == XFASTINT (name))`20
  97. X- `09`7B
  98. X- `09  if (ptr->process_active)
  99. X- `09    return Qt;
  100. X-`20
  101. X- `09  /* Delete this process and run its exit handler.  */
  102. X- `09  if (prev)
  103. X- `09    prev->next = next;
  104. X- `09  else
  105. X- `09    process_list = next;
  106. X- `09  if (! NULL (ptr->exit_handler))
  107. X- `09    Feval (Fcons (ptr->exit_handler, Fcons (make_number (ptr->name),
  108. X- `09`09`09`09`09`09    Qnil)));
  109. X- `09  sys$dassgn (ptr->mbx_chan);
  110. X- `09  break;
  111. X- `09`7D
  112. X-       else
  113. X- `09prev = ptr;
  114. X-       ptr = next;
  115. X-     `7D
  116. X-   if (! ptr)
  117. X-     ptr = (struct process_list *) xmalloc (sizeof (struct process_list));
  118. X-`20
  119. X-   if (! create_mbx (&output_mbx_dsc, output_mbx_name, &ptr->mbx_chan, 2))
  120. X-     `7B
  121. X-       free (ptr);
  122. X-       return Qnil;
  123. X-     `7D
  124. X-   if (NULL (input_handler))
  125. X-     input_handler = Qdefault_subproc_input_handler;
  126. X-   ptr->input_handler = input_handler;
  127. X-   ptr->exit_handler = exit_handler;
  128. X-   message ("Creating subprocess...");
  129. X-   status = lib$spawn (0, &output_mbx_dsc, &input_mbx_dsc, &dummy, 0,
  130. X-                       &ptr->process_id, 0, 0, exit_ast, &ptr->process_acti
  131. Vve);
  132. X-   if (! (status & 1))
  133. X-     `7B
  134. X-       sys$dassgn (ptr->mbx_chan);
  135. X-       free (ptr);
  136. X-       error ("Unable to spawn subprocess");
  137. X-       return Qnil;
  138. X-     `7D
  139. X-   ptr->name = XFASTINT (name);
  140. X-   ptr->next = process_list;
  141. X-   ptr->process_active = 1;
  142. X-   process_list = ptr;
  143. X-   message ("Creating subprocess...done");
  144. X-   return Qt;
  145. X- `7D
  146. X-`20
  147. X- static void
  148. X- mbx_msg (ptr, msg)
  149. X-      struct process_list *ptr;
  150. X-      char *msg;
  151. X- `7B
  152. X-   write_to_mbx (ptr, msg, strlen (msg));
  153. X- `7D
  154. X-`20
  155. X- DEFUN ("send-command-to-subprocess",
  156. X-   Fsend_command_to_subprocess, Ssend_command_to_subprocess, 2, 2,
  157. X-   "sSend command to subprocess: \nsSend subprocess %s command: ",
  158. X-   "Send to VMS subprocess named NAME the string COMMAND.")
  159. X-   (name, command)
  160. X-      Lisp_Object name, command;
  161. X- `7B
  162. X-   struct process_list * ptr;
  163. X-`20
  164. X-   CHECK_NUMBER (name, 0);
  165. X-   CHECK_STRING (command, 1);
  166. X-   for (ptr = process_list; ptr; ptr = ptr->next)
  167. X-     if (XFASTINT (name) == ptr->name)
  168. X-       `7B
  169. X- `09write_to_mbx (ptr, XSTRING (command)->data,
  170. X- `09`09      XSTRING (command)->size);
  171. X- `09return Qt;
  172. X-       `7D
  173. X-   return Qnil;
  174. X- `7D
  175. X-`20
  176. X- DEFUN ("stop-subprocess", Fstop_subprocess, Sstop_subprocess, 1, 1,
  177. X-   "sStop subprocess: ", "Stop VMS subprocess named NAME.")
  178. X-   (name)
  179. X-      Lisp_Object name;
  180. X- `7B
  181. X-   struct process_list * ptr;
  182. X-`20
  183. X-   CHECK_NUMBER (name, 0);
  184. X-   for (ptr = process_list; ptr; ptr = ptr->next)
  185. X-     if (XFASTINT (name) == ptr->name)
  186. X-       `7B
  187. X- `09ptr->exit_handler = Qnil;
  188. X- `09if (sys$delprc (&ptr->process_id, 0) & 1)
  189. X- `09  ptr->process_active = 0;
  190. X- `09return Qt;
  191. X-       `7D
  192. X-   return Qnil;
  193. X- `7D
  194. X-`20
  195. X- static int
  196. X- exit_ast (active)
  197. X-      int * active;
  198. X- `7B
  199. X-   process_exited = 1;
  200. X-   *active = 0;
  201. X-   sys$setef (process_ef);
  202. X- `7D
  203. X-`20
  204. X- /* Process to handle input on the input mailbox.
  205. X-  * Searches through the list of processes until the matching PID is found,
  206. X-  * then calls its input handler.
  207. X-  */
  208. X-`20
  209. X- process_command_input ()
  210. X- `7B
  211. X-   struct process_list * ptr;
  212. X-   char * msg;
  213. X-   int msglen;
  214. X-   Lisp_Object expr;
  215. X-`20
  216. X-   msg = mbx_buffer;
  217. X-   msglen = input_iosb.size;
  218. X-   /* Hack around VMS oddity of sending extraneous CR/LF characters for
  219. X-    * some of the commands (but not most).
  220. X-    */
  221. X-   if (msglen > 0 && *msg == '\r')
  222. X-     `7B
  223. X-       msg++;
  224. X-       msglen--;
  225. X-     `7D
  226. X-   if (msglen > 0 && msg`5Bmsglen - 1`5D == '\n')
  227. X-     msglen--;
  228. X-   if (msglen > 0 && msg`5Bmsglen - 1`5D == '\r')
  229. X-     msglen--;
  230. X-   /* Search for the subprocess in the linked list.
  231. X-    */
  232. X-   expr = Qnil;
  233. X-   for (ptr = process_list; ptr; ptr = ptr->next)
  234. X-     if (ptr->process_id == input_iosb.pid)
  235. X-       `7B
  236. X- `09expr = Fcons (ptr->input_handler,
  237. X- `09`09      Fcons (make_number (ptr->name),
  238. X- `09`09`09     Fcons (make_string (msg, msglen),
  239. X- `09`09`09`09    Qnil)));
  240. X- `09break;
  241. X-       `7D
  242. X-   have_process_input = 0;
  243. X-   start_mbx_input ();
  244. X-   clear_waiting_for_input ();    /* Otherwise Ctl-g will cause crash. JCB
  245. V */
  246. X-   if (! NULL (expr))
  247. X-     Feval (expr);
  248. X- `7D
  249. X-`20
  250. X- /* Searches process list for any processes which have exited.  Calls their
  251. X-  * exit handlers and removes them from the process list.
  252. X-  */
  253. X-`20
  254. X- process_exit ()
  255. X- `7B
  256. X-   struct process_list * ptr, * prev, * next;
  257. X-`20
  258. X-   process_exited = 0;
  259. X-   prev = 0;
  260. X-   ptr = process_list;
  261. X-   while (ptr)
  262. X-     `7B
  263. X-       next = ptr->next;
  264. X-       if (! ptr->process_active)
  265. X- `09`7B
  266. X- `09  if (prev)
  267. X- `09    prev->next = next;
  268. X- `09  else
  269. X- `09    process_list = next;
  270. X- `09  if (! NULL (ptr->exit_handler))
  271. X- `09    Feval (Fcons (ptr->exit_handler, Fcons (make_number (ptr->name),
  272. X- `09`09`09`09`09`09    Qnil)));
  273. X- `09  sys$dassgn (ptr->mbx_chan);
  274. X- `09  free (ptr);
  275. X- `09`7D
  276. X-       else
  277. X- `09prev = ptr;
  278. X-       ptr = next;
  279. X-     `7D
  280. X- `7D
  281. X-`20
  282. X- /* Called at emacs exit.
  283. X-  */
  284. X-`20
  285. X- kill_vms_processes ()
  286. X- `7B
  287. X-   struct process_list * ptr;
  288. X-`20
  289. X-   for (ptr = process_list; ptr; ptr = ptr->next)
  290. X-     if (ptr->process_active)
  291. X-       `7B
  292. X- `09sys$dassgn (ptr->mbx_chan);
  293. X- `09sys$delprc (&ptr->process_id, 0);
  294. X-       `7D
  295. X-   sys$dassgn (input_mbx_chan);
  296. X-   process_list = 0;
  297. X-   input_mbx_chan = 0;
  298. X- `7D
  299. X-`20
  300. X- /* Creates a temporary mailbox and retrieves its device name in 'buf'.
  301. X-  * Makes the descriptor pointed to by 'dsc' refer to this device.
  302. X-  * 'buffer_factor' is used to allow sending messages asynchronously
  303. X-  * till some point.
  304. X-  */
  305. X-`20
  306. X- static int
  307. X- create_mbx (dsc, buf, chan, buffer_factor)
  308. X-      struct dsc$descriptor_s *dsc;
  309. X-      char *buf;
  310. X-      int *chan;
  311. X-      int buffer_factor;
  312. X- `7B
  313. X-   int strval`5B2`5D;
  314. X-   int status;
  315. X-   static int dummy = DVI$_DEVNAM;
  316. X-`20
  317. X-   status = sys$crembx (0, chan, MSGSIZE, MSGSIZE * buffer_factor, 0, 0, 0)
  318. V;
  319. X-   if (! (status & 1))
  320. X-     `7B
  321. X-       message ("Unable to create mailbox.  Need TMPMBX privilege.");
  322. X-       return 0;
  323. X-     `7D
  324. X-   strval`5B0`5D = 16;
  325. X-   strval`5B1`5D = (int) buf;
  326. X-   status = lib$getdvi (&dummy, chan, 0, 0, strval,
  327. X- `09`09       &dsc->dsc$w_length);
  328. X-   if (! (status & 1))
  329. X-     return 0;
  330. X-   dsc->dsc$b_dtype = DSC$K_DTYPE_T;
  331. X-   dsc->dsc$b_class = DSC$K_CLASS_S;
  332. X-   dsc->dsc$a_pointer = buf;
  333. X-   return 1;
  334. X- `7D`09`09`09`09/* create_mbx */
  335. X-`20
  336. X- /* AST routine to be called upon receiving mailbox input.
  337. X-  * Sets flag telling keyboard routines that input is available.
  338. X-  */
  339. X-`20
  340. X- static int
  341. X- mbx_input_ast ()
  342. X- `7B
  343. X-   have_process_input = 1;
  344. X- `7D
  345. X-`20
  346. X- /* Issue a QIO request on the input mailbox.
  347. X-  */
  348. X- static void
  349. X- start_mbx_input ()
  350. X- `7B
  351. X-   sys$qio (process_ef, input_mbx_chan, IO$_READVBLK, &input_iosb,
  352. X-            mbx_input_ast, 0, mbx_buffer, sizeof (mbx_buffer),
  353. X- `09   0, 0, 0, 0);
  354. X- `7D
  355. X-`20
  356. X- /* Send a message to the subprocess input mailbox, without blocking if
  357. X-  * possible.
  358. X-  */
  359. X- static void
  360. X- write_to_mbx (ptr, buf, len)
  361. X-      struct process_list *ptr;
  362. X-      char *buf;
  363. X-      int len;
  364. X- `7B
  365. X-   sys$qiow (0, ptr->mbx_chan, IO$_WRITEVBLK `7C IO$M_NOW, &ptr->iosb,
  366. X- `09    0, 0, buf, len, 0, 0, 0, 0);
  367. X- `7D
  368. X-`20
  369. X  DEFUN ("setprv", Fsetprv, Ssetprv, 1, 3, 0,
  370. X    "Set or reset a VMS privilege.  First arg is privilege name.\n\
  371. X  Second arg is t or nil, indicating whether the privilege is to be\n\
  372. X--- 262,267 ----
  373. X***************
  374. X*** 699,706 ****
  375. X    static int dummy = JPI$_PID;
  376. X `20
  377. X    if (NULL (pid)
  378. X!       `7C`7C XTYPE (pid) == Lisp_String && XSTRING (pid)->size == 0
  379. X!       `7C`7C XTYPE (pid) == Lisp_Int && XFASTINT (pid) == 0)
  380. X      `7B
  381. X        code = owner ? JPI$_OWNER : JPI$_PID;
  382. X        status = lib$getjpi (&code, 0, 0, &id);
  383. X--- 375,382 ----
  384. X    static int dummy = JPI$_PID;
  385. X `20
  386. X    if (NULL (pid)
  387. X!       `7C`7C (XTYPE (pid) == Lisp_String && XSTRING (pid)->size == 0)
  388. X!       `7C`7C (XTYPE (pid) == Lisp_Int && XFASTINT (pid) == 0))
  389. X      `7B
  390. X        code = owner ? JPI$_OWNER : JPI$_PID;
  391. X        status = lib$getjpi (&code, 0, 0, &id);
  392. X***************
  393. X*** 960,982 ****
  394. X  `0C
  395. X  init_vmsfns ()
  396. X  `7B
  397. X-   process_list = 0;
  398. X-   input_mbx_chan = 0;
  399. X  `7D
  400. X `20
  401. X  syms_of_vmsfns ()
  402. X  `7B
  403. X-   defsubr (&Sdefault_subproc_input_handler);
  404. X-   defsubr (&Sspawn_subprocess);
  405. X-   defsubr (&Ssend_command_to_subprocess);
  406. X-   defsubr (&Sstop_subprocess);
  407. X    defsubr (&Ssetprv);
  408. X  #ifdef VMS4_4
  409. X    defsubr (&Svms_system_info);
  410. X    defsubr (&Sshrink_to_icon);
  411. X  #endif /* VMS4_4 */
  412. X-   Qdefault_subproc_input_handler = intern ("default-subprocess-input-handl
  413. Ver");
  414. X-   staticpro (&Qdefault_subproc_input_handler);
  415. X  `7D
  416. X  #endif /* VMS */
  417. X `20
  418. X--- 636,650 ----
  419. X*** vmsmap.c`09Tue Feb 25 11:59:28 1992
  420. X--- sb12:`5Bscratch.snyder.gnu.emacs-18_58.src`5Dvmsmap.c`09Mon May 18 22:52
  421. V:08 1992
  422. X***************
  423. X*** 136,141 ****
  424. X--- 136,147 ----
  425. X  `09`09       fab.fab$l_stv, 0, map_data.datablk, 0, 0);
  426. X    if (! (status & 1))
  427. X      lib$stop (status);
  428. X+`20
  429. X+   /* lose stale cached environment data */
  430. X+   `7B
  431. X+     extern char **my_environ;
  432. X+     my_environ = 0;
  433. X+   `7D
  434. X  `7D
  435. X `20
  436. X  /* Writes the data and alloc area to the map file.
  437. $ CALL UNPACK SRC.DIFFS;2 762974686
  438. $ create 'f'
  439. X*** compile.el`09Thu Jun 25 05:41:28 1992
  440. X--- compile.el`09Thu Jul  2 10:43:12 1992
  441. X***************
  442. X*** 80,95 ****
  443. X    (compilation-forget-errors)
  444. X    (setq compilation-error-list t)
  445. X    (setq compilation-error-message error-message)
  446. X!   (setq compilation-process
  447. X! `09(start-process "compilation" "*compilation*"
  448. X! `09`09       shell-file-name
  449. X! `09`09       "-c" (concat "exec " command)))
  450. X!   (with-output-to-temp-buffer "*compilation*"
  451. X!     (princ "cd ")
  452. X!     (princ default-directory)
  453. X!     (terpri)
  454. X!     (princ command)
  455. X!     (terpri))
  456. X    (set-process-sentinel compilation-process 'compilation-sentinel)
  457. X    (let* ((thisdir default-directory)
  458. X  `09 (outbuf (process-buffer compilation-process))
  459. X--- 80,114 ----
  460. X    (compilation-forget-errors)
  461. X    (setq compilation-error-list t)
  462. X    (setq compilation-error-message error-message)
  463. X!`20
  464. X!   (if (eq system-type 'vax-vms)
  465. X!       (progn
  466. X! `09(let ((process-connection-type nil))
  467. X! `09  (setq compilation-process
  468. X! `09`09(start-process "compilation" "*compilation*" "")))
  469. X! `09(with-output-to-temp-buffer "*compilation*"
  470. X! `09  (princ "$ set default ")
  471. X! `09  (princ default-directory)
  472. X! `09  (terpri)
  473. X! `09  (princ "$ ")
  474. X! `09  (princ command)
  475. X! `09  (terpri))
  476. X! `09(process-send-string compilation-process
  477. X! `09`09`09     (concat "set default " default-directory))
  478. X! `09(process-send-string compilation-process command)
  479. X! `09(process-send-string compilation-process "eoj"))
  480. X!`20
  481. X!     (setq compilation-process
  482. X! `09  (start-process "compilation" "*compilation*"
  483. X! `09`09`09 shell-file-name
  484. X! `09`09`09 "-c" (concat "exec " command)))
  485. X!     (with-output-to-temp-buffer "*compilation*"
  486. X!       (princ "cd ")
  487. X!       (princ default-directory)
  488. X!       (terpri)
  489. X!       (princ command)
  490. X!       (terpri)))
  491. X!`20
  492. X    (set-process-sentinel compilation-process 'compilation-sentinel)
  493. X    (let* ((thisdir default-directory)
  494. X  `09 (outbuf (process-buffer compilation-process))
  495. X***************
  496. X*** 152,164 ****
  497. X    "Kill the process made by the \\`5Bcompile`5D command."
  498. X    (interactive)
  499. X    (if compilation-process
  500. X!       (interrupt-process compilation-process)))
  501. X `20
  502. X  (defun kill-grep ()
  503. X    "Kill the process made by the \\`5Bgrep`5D command."
  504. X    (interactive)
  505. X    (if compilation-process
  506. X!       (interrupt-process compilation-process)))
  507. X `20
  508. X  (defun next-error (&optional argp)
  509. X    "Visit next compilation error message and corresponding source code.
  510. X--- 171,187 ----
  511. X    "Kill the process made by the \\`5Bcompile`5D command."
  512. X    (interactive)
  513. X    (if compilation-process
  514. X!       (if (eq system-type 'vax-vms)
  515. X! `09  (kill-process compilation-process)
  516. X! `09(interrupt-process compilation-process))))
  517. X `20
  518. X  (defun kill-grep ()
  519. X    "Kill the process made by the \\`5Bgrep`5D command."
  520. X    (interactive)
  521. X    (if compilation-process
  522. X!       (if (eq system-type 'vax-vms)
  523. X! `09  (kill-process compilation-process)
  524. X! `09(interrupt-process compilation-process))))
  525. X `20
  526. X  (defun next-error (&optional argp)
  527. X    "Visit next compilation error message and corresponding source code.
  528. X*** lpr.el`09Thu Jun 25 05:41:38 1992
  529. X--- lpr.el`09Thu Jul  2 11:02:00 1992
  530. X***************
  531. X*** 21,28 ****
  532. X  ;(defconst lpr-switches nil
  533. X  ;  "*List of strings to pass as extra switch args to lpr when it is invoke
  534. Vd.")
  535. X `20
  536. X! (defvar lpr-command (if (eq system-type 'usg-unix-v)
  537. X! `09`09`09"lp" "lpr")
  538. X    "Shell command for printing a file")
  539. X `20
  540. X  (defun lpr-buffer ()
  541. X--- 21,29 ----
  542. X  ;(defconst lpr-switches nil
  543. X  ;  "*List of strings to pass as extra switch args to lpr when it is invoke
  544. Vd.")
  545. X `20
  546. X! (defvar lpr-command (cond ((eq system-type 'usg-unix-v) "lp")
  547. X! `09`09`09  ((eq system-type 'vax-vms) "print/delete")
  548. X! `09`09`09  (t "lpr"))
  549. X    "Shell command for printing a file")
  550. X `20
  551. X  (defun lpr-buffer ()
  552. X***************
  553. X*** 62,71 ****
  554. X  `09  (setq tab-width width)
  555. X  `09  (untabify (point-min) (point-max))
  556. X  `09  (setq start (point-min) end (point-max))))
  557. X!      (apply 'call-process-region
  558. X! `09    (nconc (list start end lpr-command
  559. X! `09`09`09 nil nil nil)
  560. X! `09`09   (nconc (and (eq system-type 'berkeley-unix)
  561. X! `09`09`09       (list "-J" name "-T" name))
  562. X! `09`09`09  switches)))
  563. X       (message "Spooling...done"))))
  564. X--- 63,80 ----
  565. X  `09  (setq tab-width width)
  566. X  `09  (untabify (point-min) (point-max))
  567. X  `09  (setq start (point-min) end (point-max))))
  568. X!      (if (eq system-type 'vax-vms)
  569. X! `09 (progn
  570. X! `09   (write-region start end "sys$scratch:emacs_print.tmp")
  571. X! `09   (call-process lpr-command
  572. X! `09`09`09 nil nil nil  (concat "sys$scratch:emacs_print.tmp "
  573. X! `09`09`09`09`09      (if switches
  574. X! `09`09`09`09`09`09  switches
  575. X! `09`09`09`09`09`09""))))
  576. X!        (apply 'call-process-region
  577. X! `09      (nconc (list start end lpr-command
  578. X! `09`09`09   nil nil nil)
  579. X! `09`09     (nconc (and (eq system-type 'berkeley-unix)
  580. X! `09`09`09`09 (list "-J" name "-T" name))
  581. X! `09`09`09    switches))))
  582. X       (message "Spooling...done"))))
  583. X*** shell.el`09Thu Jun 25 05:41:48 1992
  584. X--- shell.el`09Thu Jul  2 10:01:30 1992
  585. X***************
  586. X*** 154,171 ****
  587. X        (if (memq status '(run stop))
  588. X  `09  nil
  589. X  `09(if proc (delete-process proc))
  590. X! `09(setq proc (apply 'start-process name buffer
  591. X! `09`09`09  (concat exec-directory "env")
  592. X! `09`09`09  (format "TERMCAP=emacs:co#%d:tc=unknown:"
  593. X! `09`09`09`09  (screen-width))
  594. X! `09`09`09  "TERM=emacs"
  595. X! `09`09`09  "EMACS=t"
  596. X! `09`09`09  "-"
  597. X! `09`09`09  (or program explicit-shell-file-name
  598. X! `09`09`09      (getenv "ESHELL")
  599. X! `09`09`09      (getenv "SHELL")
  600. X! `09`09`09      "/bin/sh")
  601. X! `09`09`09  switches))
  602. X  `09(cond (startfile
  603. X  `09       ;;This is guaranteed to wait long enough
  604. X  `09       ;;but has bad results if the shell does not prompt at all
  605. X--- 154,175 ----
  606. X        (if (memq status '(run stop))
  607. X  `09  nil
  608. X  `09(if proc (delete-process proc))
  609. X! `09(if (not (eq system-type 'vax-vms))
  610. X! `09    (setq proc (apply 'start-process name buffer
  611. X! `09`09`09      (concat exec-directory "env")
  612. X! `09`09`09      (format "TERMCAP=emacs:co#%d:tc=unknown:"
  613. X! `09`09`09`09      (screen-width))
  614. X! `09`09`09      "TERM=emacs"
  615. X! `09`09`09      "EMACS=t"
  616. X! `09`09`09      "-"
  617. X! `09`09`09      (or program explicit-shell-file-name
  618. X! `09`09`09`09  (getenv "ESHELL")
  619. X! `09`09`09`09  (getenv "SHELL")
  620. X! `09`09`09`09  "/bin/sh")
  621. X! `09`09`09      switches))
  622. X! `09  (setq proc (apply 'start-process name buffer program switches))
  623. X! `09  (if (not process-connection-type)
  624. X! `09      (process-send-string proc "on severe_error then continue")))
  625. X  `09(cond (startfile
  626. X  `09       ;;This is guaranteed to wait long enough
  627. X  `09       ;;but has bad results if the shell does not prompt at all
  628. X***************
  629. X*** 271,277 ****
  630. X  `09`09(cd (getenv "HOME")))
  631. X  `09       ((memq (char-after (match-end 0)) '(?\  ?\t))
  632. X  `09`09(let (dir)
  633. X! `09`09  (forward-char 3)
  634. X  `09`09  (skip-chars-forward " \t")
  635. X  `09`09  (if (file-directory-p
  636. X  `09`09`09(setq dir
  637. X--- 275,283 ----
  638. X  `09`09(cd (getenv "HOME")))
  639. X  `09       ((memq (char-after (match-end 0)) '(?\  ?\t))
  640. X  `09`09(let (dir)
  641. X! `09`09  (if (eq system-type 'vax-vms)
  642. X! `09`09      (goto-char (match-end 0))
  643. X! `09`09    (forward-char 3))
  644. X  `09`09  (skip-chars-forward " \t")
  645. X  `09`09  (if (file-directory-p
  646. X  `09`09`09(setq dir
  647. X*** telnet.el`09Mon May 18 22:50:01 1992
  648. X--- telnet.el`09Mon Jun 29 00:03:46 1992
  649. X***************
  650. X*** 78,84 ****
  651. X `20
  652. X  (defun telnet-initial-filter (proc string)
  653. X    ;For reading up to and including password; also will get machine type.
  654. X!   (cond ((string-match "No such host" string)
  655. X  `09 (kill-buffer (process-buffer proc))
  656. X  `09 (error "No such host."))
  657. X  `09((string-match "passw" string)
  658. X--- 78,85 ----
  659. X `20
  660. X  (defun telnet-initial-filter (proc string)
  661. X    ;For reading up to and including password; also will get machine type.
  662. X!   (cond ((or (string-match "No such host" string)
  663. X! `09     (string-match "?Unknown INTERNET host" string))
  664. X  `09 (kill-buffer (process-buffer proc))
  665. X  `09 (error "No such host."))
  666. X  `09((string-match "passw" string)
  667. X***************
  668. X*** 156,165 ****
  669. X    (interactive "sOpen telnet connection to host: ")
  670. X    (require 'shell)
  671. X    (let ((name (concat arg "-telnet" )))
  672. X!     (switch-to-buffer (make-shell name "telnet"))
  673. X      (set-process-filter (get-process name) 'telnet-initial-filter)
  674. X      (erase-buffer)
  675. X!     (send-string  name (concat "open " arg "\n"))
  676. X      (telnet-mode)
  677. X      (setq telnet-count -16)))
  678. X `20
  679. X--- 157,169 ----
  680. X    (interactive "sOpen telnet connection to host: ")
  681. X    (require 'shell)
  682. X    (let ((name (concat arg "-telnet" )))
  683. X!     (if (eq system-type 'vax-vms)
  684. X! `09(switch-to-buffer (make-shell name "telnet" nil arg))
  685. X!       (switch-to-buffer (make-shell name "telnet")))
  686. X      (set-process-filter (get-process name) 'telnet-initial-filter)
  687. X      (erase-buffer)
  688. X!     (if (not (eq system-type 'vax-vms))
  689. X! `09(send-string name (concat "open " arg "\n")))
  690. X      (telnet-mode)
  691. X      (setq telnet-count -16)))
  692. X `20
  693. X*** version.el`09Mon May 18 22:50:05 1992
  694. X--- version.el`09Thu Jun 25 04:34:05 1992
  695. X***************
  696. X*** 33,39 ****
  697. X    (interactive)
  698. X    (if (interactive-p)
  699. X        (message "%s" (emacs-version))
  700. X!     (format "GNU Emacs %s of %s %s on %s (%s)"
  701. X  `09    emacs-version
  702. X  `09    (substring emacs-build-time 0
  703. X  `09`09       (string-match " *`5B0-9`5D*:" emacs-build-time))
  704. X--- 33,39 ----
  705. X    (interactive)
  706. X    (if (interactive-p)
  707. X        (message "%s" (emacs-version))
  708. X!     (format "GNU Emacs %s of %s %s on %s (%s) (sss hacked version)"
  709. X  `09    emacs-version
  710. X  `09    (substring emacs-build-time 0
  711. X  `09`09       (string-match " *`5B0-9`5D*:" emacs-build-time))
  712. X*** vms-patch.el`09Mon May 18 22:50:06 1992
  713. X--- vms-patch.el`09Wed Jun 24 13:29:45 1992
  714. X***************
  715. X*** 82,84 ****
  716. X--- 82,98 ----
  717. X    nil)
  718. X `20
  719. X  (setq suspend-hook 'vms-suspend-hook)
  720. X+`20
  721. X+ ;;; variable settings to get shell mode to work
  722. X+`20
  723. X+ (setq explicit-shell-file-name "")
  724. X+ (setq shell-cd-regexp
  725. X+       "cd\\`7Csd\\`7Cset +\\(default\\`7Cdefaul\\`7Cdefau\\`7Cdefa\\`7Cdef
  726. V\\)")
  727. X+ (setq explicit--args '(""))
  728. X+ (setq shell-prompt-pattern "\\$")
  729. X+`20
  730. X+ ;;; additional automodes for vms
  731. X+`20
  732. X+ (setq auto-mode-alist
  733. X+       (cons '("\\.for$" . fortran-mode) auto-mode-alist))
  734. X+`20
  735. $ CALL UNPACK LISP.DIFFS;8 958870403
  736. $ create 'f'
  737. X/*
  738. X * s-vms5-4.h
  739. X */
  740. X
  741. X#include "s-vms.h"
  742. X#define VMS5_4
  743. X#define VMS4_4
  744. X
  745. X#define HAVE_VMS_PTYS
  746. $ CALL UNPACK S-VMS5-4.H;1 591162484
  747. $ create 'f'
  748. X;;; Missing: P command, sorting, setting file modes.
  749. X;;; Dired buffer containing multiple directories gets totally confused
  750. X;;; Implement insertion of subdirectories in situ --- tree dired
  751. X;;; Added `5B22-Oct-88`5D: support for VAX VMS
  752. X
  753. X;; DIRED commands for Emacs
  754. X;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
  755. X
  756. X;; This file is part of GNU Emacs.
  757. X
  758. X;; GNU Emacs is distributed in the hope that it will be useful,
  759. X;; but WITHOUT ANY WARRANTY.  No author or distributor
  760. X;; accepts responsibility to anyone for the consequences of using it
  761. X;; or for whether it serves any particular purpose or works at all,
  762. X;; unless he says so in writing.  Refer to the GNU Emacs General Public
  763. X;; License for full details.
  764. X
  765. X;; Everyone is granted permission to copy, modify and redistribute
  766. X;; GNU Emacs, but only under the conditions described in the
  767. X;; GNU Emacs General Public License.   A copy of this license is
  768. X;; supposed to have been given to you along with GNU Emacs so you
  769. X;; can know your rights and responsibilities.  It should be in a
  770. X;; file named COPYING.  Among other things, the copyright notice
  771. X;; and this notice must be preserved on all copies.
  772. X
  773. X
  774. X;In loaddefs.el
  775. X;(defvar dired-listing-switches "-al"
  776. X;  "Switches passed to ls for dired. MUST contain the 'l' option.
  777. X;CANNOT contain the 'F' option.")
  778. X
  779. X(defvar dired-directory-command
  780. X  "DIRECTORY/SIZE/DATE/OWNER/WIDTH=(FILENAME=32,SIZE=5)"
  781. X  "Directory command for dired")
  782. X
  783. X(if (eq system-type 'vax-vms)
  784. X    (setq dired-listing-switches ""))
  785. X
  786. X(defun dired-readin (dirname buffer)
  787. X  (save-excursion
  788. X    (message "Reading directory %s..." dirname)
  789. X    (set-buffer buffer)
  790. X    (let ((buffer-read-only nil))
  791. X      (widen)
  792. X      (erase-buffer)
  793. X`09  (dired-read-directory dirname buffer)
  794. X      (goto-char (point-min))
  795. X      (while (not (eobp))
  796. X`09(insert "  ")
  797. X`09(forward-line 1))
  798. X      (goto-char (point-min)))
  799. X    (message "Reading directory %s...done" dirname)))
  800. X
  801. X(defun dired-read-directory (dirname buffer)
  802. X  (if (eq system-type 'vax-vms)
  803. X      (progn
  804. X;`09(subprocess-command-to-buffer (concat
  805. X;`09`09`09`09       dired-directory-command " "
  806. X;`09`09`09`09       dirname) buffer)
  807. X`09(call-process dired-directory-command nil buffer nil dirname)
  808. X`09(save-excursion
  809. X`09  (replace-regexp " *$" "")))
  810. X    ;; otherwise UNIX style
  811. X    (setq dirname (expand-file-name dirname))
  812. X    (if (file-directory-p dirname)
  813. X`09(call-process "ls" nil buffer nil
  814. X`09`09      dired-listing-switches dirname)
  815. X      (let ((default-directory (file-name-directory dirname)))
  816. X`09(call-process shell-file-name nil buffer nil
  817. X`09`09      "-c" (concat "ls " dired-listing-switches " "
  818. X`09`09`09`09   (file-name-nondirectory dirname))))))
  819. X  )
  820. X
  821. X(defun dired-find-buffer (dirname)
  822. X  (let ((blist (buffer-list))
  823. X`09found)
  824. X    (while blist
  825. X      (save-excursion
  826. X        (set-buffer (car blist))
  827. X`09(if (and (eq major-mode 'dired-mode)
  828. X`09`09 (equal dired-directory dirname))
  829. X`09    (setq found (car blist)
  830. X`09`09  blist nil)
  831. X`09  (setq blist (cdr blist)))))
  832. X    (or found
  833. X`09(create-file-buffer (directory-file-name dirname)))))
  834. X
  835. X(defun dired (dirname)
  836. X  "\"Edit\" directory DIRNAME--delete, rename, print, etc. some files in it.
  837. XDired displays a list of files in DIRNAME.
  838. XYou can move around in it with the usual commands.
  839. XYou can flag files for deletion with C-d
  840. Xand then delete them by typing `60x'.
  841. XType `60h' after entering dired for more info."
  842. X  (interactive (list (read-file-name "Dired (directory): "
  843. X`09`09`09`09     nil default-directory nil)))
  844. X  (switch-to-buffer (dired-noselect dirname)))
  845. X
  846. X(defun dired-other-window (dirname)
  847. X  "\"Edit\" directory DIRNAME.  Like M-x dired but selects in another window
  848. V."
  849. X  (interactive (list (read-file-name "Dired in other window (directory): "
  850. X`09`09`09`09     nil default-directory nil)))
  851. X  (switch-to-buffer-other-window (dired-noselect dirname)))
  852. X
  853. X(defun dired-noselect (dirname)
  854. X  "Like M-x dired but returns the dired buffer as value, does not select it.
  855. V"
  856. X;;;  (or dirname (setq dirname default-directory))
  857. X;;;  (setq dirname (expand-file-name (directory-file-name dirname)))
  858. X;;;  (if (file-directory-p dirname)
  859. X;;;      (setq dirname (file-name-as-directory dirname)))
  860. X  (setq dirname (dired-fix-directory dirname))
  861. X  (let ((buffer (dired-find-buffer dirname)))
  862. X    (save-excursion
  863. X      (set-buffer buffer)
  864. X      (dired-readin dirname buffer)
  865. X      (dired-move-to-filename)
  866. X      (dired-mode dirname))
  867. X    buffer))
  868. X
  869. X(defun dired-fix-directory (dirname)
  870. X  "Fix up dirname to be a valid directory name and return it"
  871. X  (or dirname (setq dirname default-directory))
  872. X  (if (eq system-type 'vax-vms)
  873. X      (progn
  874. X`09(or dirname (setq dirname default-directory))
  875. X`09(setq dirname (expand-file-name dirname)))
  876. X  ;; else UNIX style
  877. X    (if (string-match "./$" dirname)
  878. X`09(setq dirname (substring dirname 0 -1)))
  879. X    (setq dirname (expand-file-name dirname))
  880. X    (and (not (string-match "/$" dirname))
  881. X`09 (file-directory-p dirname)
  882. X`09 (setq dirname (concat dirname "/")))
  883. X    dirname
  884. X    ))
  885. X
  886. X(defun dired-revert (&optional arg noconfirm)
  887. X  (let ((opoint (point))
  888. X`09(ofile (dired-get-filename t t))
  889. X`09(buffer-read-only nil))
  890. X    (erase-buffer)
  891. X    (dired-readin dired-directory (current-buffer))
  892. X    (or (and ofile (re-search-forward (concat " " (regexp-quote ofile) "$")
  893. X`09`09`09`09      nil t))
  894. X`09(goto-char opoint))
  895. X    (beginning-of-line)))
  896. X
  897. X(defvar dired-match-date
  898. X `09   "\\(Jan\\`7CFeb\\`7CMar\\`7CApr\\`7CMay\\`7CJun\\`7CJul\\`7CAug\\`7CS
  899. Vep\\`7COct\\`7CNov\\`7CDec\\)`5B `5D+`5B0-9`5D+"
  900. X`09   "Regexp to match the date on a filename")
  901. X
  902. X(defvar dired-mode-map nil "Local keymap for dired-mode buffers.")
  903. X(if dired-mode-map
  904. X    nil
  905. X  (setq dired-mode-map (make-keymap))
  906. X  (suppress-keymap dired-mode-map)
  907. X  (define-key dired-mode-map "r" 'dired-rename-file)
  908. X  (define-key dired-mode-map "\C-d" 'dired-flag-file-deleted)
  909. X  (define-key dired-mode-map "d" 'dired-flag-file-deleted)
  910. X  (define-key dired-mode-map "v" 'dired-view-file)
  911. X  (define-key dired-mode-map "e" 'dired-find-file)
  912. X  (define-key dired-mode-map "f" 'dired-find-file)
  913. X  (define-key dired-mode-map "o" 'dired-find-file-other-window)
  914. X  (define-key dired-mode-map "u" 'dired-unflag)
  915. X  (define-key dired-mode-map "x" 'dired-do-deletions)
  916. X  (define-key dired-mode-map "\177" 'dired-backup-unflag)
  917. X  (define-key dired-mode-map "?" 'dired-summary)
  918. X  (define-key dired-mode-map "c" 'dired-copy-file)
  919. X  (define-key dired-mode-map "#" 'dired-flag-auto-save-files)
  920. X  (define-key dired-mode-map "`7E" 'dired-flag-backup-files)
  921. X  (define-key dired-mode-map "." 'dired-clean-directory)
  922. X  (define-key dired-mode-map "h" 'describe-mode)
  923. X  (define-key dired-mode-map " "  'dired-next-line)
  924. X  (define-key dired-mode-map "\C-n" 'dired-next-line)
  925. X  (define-key dired-mode-map "\C-p" 'dired-previous-line)
  926. X  (define-key dired-mode-map "n" 'dired-next-line)
  927. X  (define-key dired-mode-map "p" 'dired-previous-line)
  928. X  (define-key dired-mode-map "g" 'revert-buffer)
  929. X  (define-key dired-mode-map "C" 'dired-compress)
  930. X  (define-key dired-mode-map "U" 'dired-uncompress)
  931. X  (define-key dired-mode-map "B" 'dired-byte-recompile)
  932. X  (define-key dired-mode-map "M" 'dired-chmod)
  933. X  (define-key dired-mode-map "G" 'dired-chgrp)
  934. X  (define-key dired-mode-map "O" 'dired-chown))
  935. X
  936. X
  937. X;; Dired mode is suitable only for specially formatted data.
  938. X(put 'dired-mode 'mode-class 'special)
  939. X
  940. X(defun dired-mode (&optional dirname)
  941. X  "Mode for \"editing\" directory listings.
  942. XIn dired, you are \"editing\" a list of the files in a directory.
  943. XYou can move using the usual cursor motion commands.
  944. XLetters no longer insert themselves.
  945. XInstead, type d to flag a file for Deletion.
  946. XType u to Unflag a file (remove its D flag).
  947. X  Type Rubout to back up one line and unflag.
  948. XType x to eXecute the deletions requested.
  949. XType f to Find the current line's file
  950. X  (or Dired it, if it is a directory).
  951. XType o to find file or dired directory in Other window.
  952. XType # to flag temporary files (names beginning with #) for Deletion.
  953. XType `7E to flag backup files (names ending with `7E) for Deletion.
  954. XType . to flag numerical backups for Deletion.
  955. X  (Spares dired-kept-versions or its numeric argument.)
  956. XType r to rename a file.
  957. XType c to copy a file.
  958. XType v to view a file in View mode, returning to Dired when done.
  959. XType g to read the directory again.  This discards all deletion-flags.
  960. XSpace and Rubout can be used to move down and up by lines.
  961. XAlso: C -- compress this file.  U -- uncompress this file.
  962. X      B -- byte compile this file.
  963. X M, G, O -- change file's mode, group or owner.
  964. X\\`7Bdired-mode-map`7D"
  965. X  (interactive)
  966. X  (kill-all-local-variables)
  967. X  (make-local-variable 'revert-buffer-function)
  968. X  (setq revert-buffer-function 'dired-revert)
  969. X  (setq major-mode 'dired-mode)
  970. X  (setq mode-name "Dired")
  971. X  (make-local-variable 'dired-directory)
  972. X  (setq dired-directory (or dirname default-directory))
  973. X  (if dirname
  974. X      (setq default-directory
  975. X`09    (if (file-directory-p dirname)
  976. X`09`09dirname (file-name-directory dirname))))
  977. X  (setq mode-line-buffer-identification '("Dired: %17b"))
  978. X  (setq case-fold-search nil)
  979. X  (setq buffer-read-only t)
  980. X  (use-local-map dired-mode-map)
  981. X  (run-hooks 'dired-mode-hook))
  982. X`0C
  983. X(defun dired-repeat-over-lines (arg function)
  984. X  (beginning-of-line)
  985. X  (while (and (> arg 0) (not (eobp)))
  986. X    (setq arg (1- arg))
  987. X    (save-excursion
  988. X      (beginning-of-line)
  989. X      (and (bobp) (looking-at "  total")
  990. X`09   (error "No file on this line"))
  991. X      (funcall function))
  992. X    (forward-line 1)
  993. X    (dired-move-to-filename))
  994. X  (while (and (< arg 0) (not (bobp)))
  995. X    (setq arg (1+ arg))
  996. X    (forward-line -1)
  997. X    (dired-move-to-filename)
  998. X    (save-excursion
  999. X      (beginning-of-line)
  1000. X      (funcall function))))
  1001. X
  1002. X(defun dired-flag-file-deleted (arg)
  1003. X  "In dired, flag the current line's file for deletion.
  1004. XWith arg, repeat over several lines."
  1005. X  (interactive "p")
  1006. X  (dired-repeat-over-lines arg
  1007. X    '(lambda ()
  1008. X       (let ((buffer-read-only nil))
  1009. X`09 (delete-char 1)
  1010. X`09 (insert "D")))))
  1011. X
  1012. X(defun dired-summary ()
  1013. X  (interactive)
  1014. X  ;>> this should check the key-bindings and use substitute-command-keys if
  1015. V non-standard
  1016. X  (message
  1017. X   "d-elete, u-ndelete, x-ecute, f-ind, o-ther window, r-ename, c-opy, v-iew
  1018. V"))
  1019. X
  1020. X(defun dired-unflag (arg)
  1021. X  "In dired, remove the current line's delete flag then move to next line."
  1022. X  (interactive "p")
  1023. X  (dired-repeat-over-lines arg
  1024. X    '(lambda ()
  1025. X       (let ((buffer-read-only nil))
  1026. X`09 (delete-char 1)
  1027. X`09 (insert " ")
  1028. X`09 (forward-char -1)))))
  1029. X
  1030. X(defun dired-backup-unflag (arg)
  1031. X  "In dired, move up a line and remove deletion flag there."
  1032. X  (interactive "p")
  1033. X  (dired-unflag (- arg)))
  1034. X
  1035. X(defun dired-next-line (arg)
  1036. X  "Move down ARG lines then position at filename."
  1037. X  (interactive "p")
  1038. X  (next-line arg)
  1039. X  (dired-move-to-filename))
  1040. X
  1041. X(defun dired-previous-line (arg)
  1042. X  "Move up ARG lines then position at filename."
  1043. X  (interactive "p")
  1044. X  (previous-line arg)
  1045. X  (dired-move-to-filename))
  1046. X
  1047. X(defun dired-find-file ()
  1048. X  "In dired, visit the file or directory named on this line."
  1049. X  (interactive)
  1050. X  (find-file (dired-get-filename)))
  1051. X
  1052. X(defun dired-view-file ()
  1053. X  "In dired, examine a file in view mode, returning to dired when done."
  1054. X  (interactive)
  1055. X  (if (file-directory-p (dired-get-filename))
  1056. X      (dired (dired-get-filename))
  1057. X    (view-file (dired-get-filename))))
  1058. X
  1059. X(defun dired-find-file-other-window ()
  1060. X  "In dired, visit this file or directory in another window."
  1061. X  (interactive)
  1062. X  (find-file-other-window (dired-get-filename)))
  1063. X
  1064. X(defun dired-get-filename (&optional localp no-error-if-not-filep)
  1065. X  "In dired, return name of file mentioned on this line.
  1066. XValue returned normally includes the directory name.
  1067. XA non-nil 1st argument means do not include it.  A non-nil 2nd argument
  1068. Xsays return nil if no filename on this line, otherwise an error occurs."
  1069. X  (let (eol)
  1070. X    (save-excursion
  1071. X      (end-of-line)
  1072. X      (setq eol (point))
  1073. X      (beginning-of-line)
  1074. X      (if (eq system-type 'vax-vms)
  1075. X`09  (progn
  1076. X`09    (if (and (not (looking-at "..Directory "))
  1077. X`09`09     (not (looking-at "..Total "))
  1078. X`09`09     (re-search-forward "`5E..\\(`5B`5D`5B.A-Z-0-9_$;<>`5D+\\)"
  1079. X`09`09`09`09`09eol t))
  1080. X`09`09(progn
  1081. X`09`09  (buffer-substring (match-beginning 1) (match-end 1))
  1082. X`09`09  )
  1083. X`09      (if no-error-if-not-filep nil
  1084. X`09`09(error "No file on this line"))))
  1085. X`09;; else UNIX style
  1086. X`09(if (re-search-forward dired-match-date
  1087. X`09`09`09       eol t)
  1088. X`09    (progn (skip-chars-forward " ")
  1089. X`09`09   (skip-chars-forward "`5E " eol)
  1090. X`09`09   (skip-chars-forward " " eol)
  1091. X`09`09   (let ((beg (point)))
  1092. X`09`09     (skip-chars-forward "`5E \n")
  1093. X`09`09     (if localp
  1094. X`09`09`09 (buffer-substring beg (point))
  1095. X`09`09       ;; >> uses default-directory, could lose on cd, multiple.
  1096. X`09`09       (concat default-directory
  1097. X`09`09`09       (buffer-substring beg (point))))))
  1098. X`09  (if no-error-if-not-filep nil
  1099. X`09    (error "No file on this line"))))
  1100. X      )))
  1101. X
  1102. X(defun dired-move-to-filename ()
  1103. X  "In dired, move to first char of filename on this line.
  1104. XReturns position (point) or nil if no filename on this line."
  1105. X  (let ((eol (progn (end-of-line) (point))))
  1106. X    (beginning-of-line)
  1107. X    (if (re-search-forward
  1108. X`09 "\\(Jan\\`7CFeb\\`7CMar\\`7CApr\\`7CMay\\`7CJun\\`7CJul\\`7CAug\\`7CSep\
  1109. V\`7COct\\`7CNov\\`7CDec\\)`5B `5D+`5B0-9`5D+"
  1110. X`09 eol t)
  1111. X`09(progn
  1112. X`09  (skip-chars-forward " ")
  1113. X`09  (skip-chars-forward "`5E " eol)
  1114. X`09  (skip-chars-forward " " eol)
  1115. X`09  (point)))))
  1116. X
  1117. X(defun dired-map-dired-file-lines (fn)
  1118. X  "perform fn with point at the end of each non-directory line:
  1119. Xarguments are the short and long filename"
  1120. X  (save-excursion
  1121. X    (let (filename longfilename (buffer-read-only nil))
  1122. X      (goto-char (point-min))
  1123. X      (while (not (eobp))
  1124. X`09(save-excursion
  1125. X`09  (and (not (looking-at "  d"))
  1126. X`09       (not (eolp))
  1127. X`09       (setq filename (dired-get-filename t t)
  1128. X`09`09     longfilename (dired-get-filename nil t))
  1129. X`09       (progn (end-of-line)
  1130. X`09`09      (funcall fn filename longfilename))))
  1131. X`09(forward-line 1)))))
  1132. X`0C
  1133. X(defun dired-flag-auto-save-files ()
  1134. X  "Flag for deletion files whose names suggest they are auto save files."
  1135. X  (interactive)
  1136. X  (save-excursion
  1137. X   (let ((buffer-read-only nil))
  1138. X     (goto-char (point-min))
  1139. X     (while (not (eobp))
  1140. X       (and (not (looking-at "  d"))
  1141. X`09    (not (eolp))
  1142. X`09    (if (fboundp 'auto-save-file-name-p)
  1143. X`09`09(let ((fn (dired-get-filename t t)))
  1144. X`09`09  (if fn (auto-save-file-name-p fn)))
  1145. X`09      (if (dired-move-to-filename)
  1146. X`09`09  (looking-at "#")))
  1147. X`09    (progn (beginning-of-line)
  1148. X`09`09   (delete-char 1)
  1149. X`09`09   (insert "D")))
  1150. X       (forward-line 1)))))
  1151. X
  1152. X(defun dired-clean-directory (keep)
  1153. X  "Flag numerical backups for Deletion.
  1154. XSpares dired-kept-versions latest versions, and kept-old-versions oldest.
  1155. XPositive numeric arg overrides dired-kept-versions;
  1156. Xnegative numeric arg overrides kept-old-versions with minus the arg."
  1157. X  (interactive "P")
  1158. X  (setq keep (if keep (prefix-numeric-value keep) dired-kept-versions))
  1159. X  (let ((early-retention (if (< keep 0) (- keep) kept-old-versions))
  1160. X`09(late-retention (if (<= keep 0) dired-kept-versions keep))
  1161. X`09(file-version-assoc-list ()))
  1162. X    ;; Look at each file.
  1163. X    ;; If the file has numeric backup versions,
  1164. X    ;; put on file-version-assoc-list an element of the form
  1165. X    ;; (FILENAME . VERSION-NUMBER-LIST)
  1166. X    (dired-map-dired-file-lines 'dired-collect-file-versions)
  1167. +-+-+-+-+-+-+-+-  END  OF PART 3 +-+-+-+-+-+-+-+-
  1168.