| | 207 | |
| | 208 | ;; ライブラリのロード |
| | 209 | |
| | 210 | (load "myprog" t) ; nil |
| | 211 | (autoload 'my-text-mode "my-text") ; (autoload "my-text" nil nil nil) |
| | 212 | (eval-after-load "sample" |
| | 213 | '(define-key sample-mode-map "\C-c\C-y" 'my-sample-cmd)) ; nil |
| | 214 | |
| | 215 | ;; 機能 |
| | 216 | |
| | 217 | (provide 'my-text-mode) ; my-text-mode |
| | 218 | (require 'my-text-mode) ; my-text-mode |
| | 219 | (require 'my-text-mode "my-text") ; my-text-mode |
| | 220 | (unload-feature 'my-text-mode) |
| | 221 | (unload-feature 'my-text-mode t) ; nil |
| | 222 | |
| | 223 | ;; ライブラリの存在場所を探す |
| | 224 | |
| | 225 | (when (locate-library "foo") |
| | 226 | (autoload 'foo-start "foo" "Start foo." t)) ; nil |
| | 227 | (locate-library "emacs" t (split-string (getenv "PATH") ":")) ; "/usr/bin/emacs" |
| | 228 | |
| | 229 | ;; 編集に関連するオブジェクト |
| | 230 | |
| | 231 | (current-buffer) ; #<buffer *scratch*> |
| | 232 | (point-marker) ; #<marker at 246 in *scratch*> |
| | 233 | (previous-window) ; #<window 3 on study.el> |
| | 234 | (selected-frame) ; #<frame Emacs@akio-no-imac.local 0x412ff0> |
| | 235 | |
| | 236 | ;; 編集に関連するオブジェクト向けの述語 |
| | 237 | |
| | 238 | (let ((buf (get-buffer-create "*temporary*"))) |
| | 239 | (kill-buffer buf) |
| | 240 | (buffer-live-p buf)) ; nil |
| | 241 | |
| | 242 | ;; メジャーモード |
| | 243 | |
| | 244 | (defvar sample-mode-hook nil) |
| | 245 | (defvar sample-mode-map nil) |
| | 246 | (unless sample-mode-map |
| | 247 | (setq sample-mode-map (make-keymap)) |
| | 248 | (define-key sample-mode-map "\t" 'indent-relative)) |
| | 249 | |
| | 250 | (defun sample-mode () |
| | 251 | "Sample major mode." |
| | 252 | (interactive) |
| | 253 | (kill-all-local-variables) |
| | 254 | (use-local-map sample-mode-map) |
| | 255 | (make-local-variable 'indent-line-function) |
| | 256 | (setq indent-line-function 'indent-relative-maybe) |
| | 257 | (setq mode-name "Sample") |
| | 258 | (setq major-mode 'sample-mode) |
| | 259 | (run-hooks 'sample-mode-hook)) |
| | 260 | |
| | 261 | ;; メジャーモードの判定 |
| | 262 | |
| | 263 | (setq auto-mode-alist |
| | 264 | (cons '("\\.smpl\\'". sample-mode) auto-mode-alist)) |
| | 265 | |
| | 266 | (setq auto-mode-alist |
| | 267 | (append '(("\\.smpl\\'" . sample-mode) ("\\.tst\\'" . test-mode)) |
| | 268 | auto-mode-alist)) |
| | 269 | |
| | 270 | ;; マイナーモード |
| | 271 | |
| | 272 | (defvar sample-minor-mode nil) |
| | 273 | (defvar sample-minor-mode-hook nil) |
| | 274 | |
| | 275 | (defun sample-minor-mode (&optional arg) |
| | 276 | "Sample minor mode." |
| | 277 | (interactive) |
| | 278 | (setq sample-minor-mode |
| | 279 | (if (null arg) (not sample-minor-mode) |
| | 280 | (> arg 0))) |
| | 281 | (if sample-minor-mode |
| | 282 | (message "Sample minor mode enabled") |
| | 283 | (message "Sample minor mode disabled")) |
| | 284 | (or (assq 'sample-minor-mode minor-mode-alist) |
| | 285 | (setq minor-mode-alist |
| | 286 | (cons '(sample-minor-mode " Sample") |
| | 287 | minor-mode-alist))) |
| | 288 | (run-hooks 'sample-minor-mode-hook)) |
| | 289 | |
| | 290 | ;; モードラインの定義 |
| | 291 | |
| | 292 | (setq mode-line-format |
| | 293 | '("" |
| | 294 | mode-line-mule-info |
| | 295 | mode-line-modified |
| | 296 | " " |
| | 297 | (-10 "" mode-line-buffer-identification) |
| | 298 | "(" |
| | 299 | (:eval (mode-line-mode-name)) |
| | 300 | "%n)--" |
| | 301 | (line-number-mode "%l" "--") |
| | 302 | ":" |
| | 303 | (column-number-mode "C%c" "--") |
| | 304 | "[%p]%" |
| | 305 | )) |
| | 306 | |
| | 307 | ;; バッファローカル変数 |
| | 308 | |
| | 309 | (make-local-variable 'tab-width) ; tab-width |
| | 310 | (setq tab-width 4) ; 4 |
| | 311 | |
| | 312 | (set (make-local-variable 'tab-width) 4) ; 4 |
| | 313 | |
| | 314 | tab-width ; 4 |
| | 315 | (default-value 'tab-width) ; 8 |
| | 316 | (kill-local-variable 'tab-width) ; tab-width |
| | 317 | tab-width ; 8 |
| | 318 | |
| | 319 | (setq-default comment-column 52) ; 52 |
| | 320 | |
| | 321 | ;; フック |
| | 322 | |
| | 323 | (add-hook 'text-mode-hook |
| | 324 | (lambda () |
| | 325 | (set (make-local-variable 'case-fold-search) nil) |
| | 326 | (abbrev-mode 1))) ; ((lambda nil (set (make-local-variable ...) nil) (abbrev-mode 1)) text-mode-hook-identify) |
| | 327 | |
| | 328 | (defun sample-func () |
| | 329 | (set (make-local-variable 'case-fold-search) nil) |
| | 330 | (abbrev-mode 1)) ; sample-func |
| | 331 | (add-hook 'text-mode-hook 'sample-func) ; (sample-func (lambda nil (set (make-local-variable ...) nil) (abbrev-mode 1)) text-mode-hook-identify) |
| | 332 | |
| | 333 | (remove-hook 'text-mode-hook |
| | 334 | (lambda () |
| | 335 | (set (make-local-variable 'case-fold-search) nil) |
| | 336 | (abbrev-mode 1))) ; (sample-func text-mode-hook-identify) |
| | 337 | (remove-hook 'text-mode-hook |
| | 338 | 'sample-func) ; (text-mode-hook-identify) |