(Documentation): Describe how man pages with
[bpt/emacs.git] / lisp / dos-fns.el
CommitLineData
007c61fa
RS
1;;; dos-fns.el --- MS-Dos specific functions.
2
9596811a 3;; Copyright (C) 1991, 1993, 1995, 1996 Free Software Foundation, Inc.
007c61fa 4
0acdb863 5;; Maintainer: Morten Welinder <terra@diku.dk>
007c61fa
RS
6;; Keywords: internal
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation; either version 2, or (at your option)
13;; any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
b578f267
EN
21;; along with GNU Emacs; see the file COPYING. If not, write to the
22;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23;; Boston, MA 02111-1307, USA.
007c61fa
RS
24
25;;; Commentary:
26
27;; Part of this code is taken from (or derived from) demacs.
28
29;;; Code:
30
44998f5b
RS
31;; This overrides a trivial definition in files.el.
32(defun convert-standard-filename (filename)
33 "Convert a standard file's name to something suitable for the current OS.
34This function's standard definition is trivial; it just returns the argument.
35However, on some systems, the function is redefined
36with a definition that really does change some file names."
9c777199
RS
37 (if (or (msdos-long-file-names)
38 (not (stringp filename))
39 (member (file-name-nondirectory filename) '("" "." "..")))
40 filename
41 (let* ((dir (file-name-directory filename))
42 (string (copy-sequence (file-name-nondirectory filename)))
43 (lastchar (aref string (1- (length string))))
44 i firstdot)
9c777199
RS
45 ;; Change a leading period to a leading underscore.
46 (if (= (aref string 0) ?.)
47 (aset string 0 ?_))
48 ;; Get rid of invalid characters.
49 (while (setq i (string-match
50 "[^-a-zA-Z0-9_.%~^$!#&{}@`'()\200-\376]"
51 string))
52 (aset string i ?_))
53 ;; If we don't have a period,
54 ;; and we have a dash or underscore that isn't the first char,
55 ;; change that to a period.
56 (if (and (not (string-match "\\." string))
57 (setq i (string-match "[-_]" string 1)))
58 (aset string i ?\.))
59 ;; If we don't have a period in the first 8 chars, insert one.
60 (if (> (or (string-match "\\." string)
61 (length string))
62 8)
63 (setq string
64 (concat (substring string 0 8)
65 "."
66 (substring string 8))))
67 (setq firstdot (or (string-match "\\." string) (1- (length string))))
68 ;; Truncate to 3 chars after the first period.
69 (if (> (length string) (+ firstdot 4))
70 (setq string (substring string 0 (+ firstdot 4))))
71 ;; Change all periods except the first one into underscores.
72 (while (string-match "\\." string (1+ firstdot))
73 (setq i (string-match "\\." string (1+ firstdot)))
74 (aset string i ?_))
75 ;; If the last character of the original filename was `~',
76 ;; make sure the munged name ends with it also.
77 (if (equal lastchar ?~)
78 (aset string (1- (length string)) lastchar))
79 (concat dir string))))
44998f5b 80
feb65403
RS
81;; See dos-vars.el for defcustom.
82(defvar msdos-shells)
007c61fa 83
224116b8
AI
84;;; Override setting chosen at startup.
85(defun set-default-process-coding-system ()
86 (setq default-process-coding-system
87 (if default-enable-multibyte-characters
88 '(undecided-dos . undecided-dos)
89 '(raw-text-dos . raw-text-dos))))
90
91(add-hook 'before-init-hook 'set-default-process-coding-system)
92
cafef6ab 93(defvar register-name-alist
007c61fa 94 '((ax . 0) (bx . 1) (cx . 2) (dx . 3) (si . 4) (di . 5)
21f2acd3
RS
95 (cflag . 6) (flags . 7)
96 (al . (0 . 0)) (bl . (1 . 0)) (cl . (2 . 0)) (dl . (3 . 0))
97 (ah . (0 . 1)) (bh . (1 . 1)) (ch . (2 . 1)) (dh . (3 . 1))))
007c61fa
RS
98
99(defun make-register ()
100 (make-vector 8 0))
101
102(defun register-value (regs name)
21f2acd3 103 (let ((where (cdr (assoc name register-name-alist))))
007c61fa
RS
104 (cond ((consp where)
105 (let ((tem (aref regs (car where))))
106 (if (zerop (cdr where))
107 (% tem 256)
108 (/ tem 256))))
109 ((numberp where)
110 (aref regs where))
111 (t nil))))
112
113(defun set-register-value (regs name value)
114 (and (numberp value)
21f2acd3
RS
115 (>= value 0)
116 (let ((where (cdr (assoc name register-name-alist))))
007c61fa 117 (cond ((consp where)
21f2acd3
RS
118 (let ((tem (aref regs (car where)))
119 (value (logand value 255)))
120 (aset regs
121 (car where)
122 (if (zerop (cdr where))
123 (logior (logand tem 65280) value)
124 (logior (logand tem 255) (lsh value 8))))))
007c61fa 125 ((numberp where)
21f2acd3 126 (aset regs where (logand value 65535))))))
007c61fa
RS
127 regs)
128
129(defsubst intdos (regs)
130 (int86 33 regs))
131
70662974
RS
132;; Backward compatibility for obsolescent functions which
133;; set screen size.
134
135(defun mode25 ()
136 "Changes the number of screen rows to 25."
137 (interactive)
138 (set-frame-size (selected-frame) 80 25))
139
140(defun mode4350 ()
141 "Changes the number of rows to 43 or 50.
142Emacs always tries to set the screen height to 50 rows first.
143If this fails, it will try to set it to 43 rows, on the assumption
144that your video hardware might not support 50-line mode."
145 (interactive)
146 (set-frame-size (selected-frame) 80 50)
147 (if (eq (frame-height (selected-frame)) 50)
148 nil ; the original built-in function returned nil
149 (set-frame-size (selected-frame) 80 43)))
150
868c7abd
RS
151(provide 'dos-fns)
152
153; dos-fns.el ends here