diff options
| author | Stefan Monnier | 2006-04-11 16:48:17 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2006-04-11 16:48:17 +0000 |
| commit | 37dc47675c697836b29fe203efb081423c0d0318 (patch) | |
| tree | 6670e91739c13538f2a7471af17b0195aeb19f45 | |
| parent | 866d0913b19ddaeec9294e5627e5453029ef2978 (diff) | |
| download | emacs-37dc47675c697836b29fe203efb081423c0d0318.tar.gz emacs-37dc47675c697836b29fe203efb081423c0d0318.zip | |
(hexl-isearch-search-function): Fix regexp-building code to
quote special chars, and make the trick work on the hex part of the
buffer as well.
(hexl-mode, hexl-save-buffer, hexl-mode-exit)
(hexl-maybe-dehexlify-buffer): Use restore-buffer-modified-p.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/hexl.el | 74 |
2 files changed, 46 insertions, 34 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 13f26abcbfd..747781efcb6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2006-04-11 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2006-04-11 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * hexl.el (hexl-isearch-search-function): Fix regexp-building code to | ||
| 4 | quote special chars, and make the trick work on the hex part of the | ||
| 5 | buffer as well. | ||
| 6 | (hexl-mode, hexl-save-buffer, hexl-mode-exit) | ||
| 7 | (hexl-maybe-dehexlify-buffer): Use restore-buffer-modified-p. | ||
| 8 | |||
| 3 | * startup.el (normal-splash-screen): Fix last change so we don't wait | 9 | * startup.el (normal-splash-screen): Fix last change so we don't wait |
| 4 | 2 minutes if we don't show the splash screen. | 10 | 2 minutes if we don't show the splash screen. |
| 5 | 11 | ||
diff --git a/lisp/hexl.el b/lisp/hexl.el index bdece19f96b..1e724aa418a 100644 --- a/lisp/hexl.el +++ b/lisp/hexl.el | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | ;; grouping. | 38 | ;; grouping. |
| 39 | ;; | 39 | ;; |
| 40 | ;; -iso in `hexl-options' will allow iso characters to display in the | 40 | ;; -iso in `hexl-options' will allow iso characters to display in the |
| 41 | ;; ASCII region of the screen (if your emacs supports this) instead of | 41 | ;; ASCII region of the screen (if your Emacs supports this) instead of |
| 42 | ;; changing them to dots. | 42 | ;; changing them to dots. |
| 43 | 43 | ||
| 44 | ;;; Code: | 44 | ;;; Code: |
| @@ -62,7 +62,7 @@ and \"-de\" when dehexlifying a buffer." | |||
| 62 | :group 'hexl) | 62 | :group 'hexl) |
| 63 | 63 | ||
| 64 | (defcustom hexl-iso "" | 64 | (defcustom hexl-iso "" |
| 65 | "If your emacs can handle ISO characters, this should be set to | 65 | "If your Emacs can handle ISO characters, this should be set to |
| 66 | \"-iso\" otherwise it should be \"\"." | 66 | \"-iso\" otherwise it should be \"\"." |
| 67 | :type 'string | 67 | :type 'string |
| 68 | :group 'hexl) | 68 | :group 'hexl) |
| @@ -229,7 +229,7 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode. | |||
| 229 | original-point)) | 229 | original-point)) |
| 230 | (or (bolp) (setq original-point (1- original-point)))) | 230 | (or (bolp) (setq original-point (1- original-point)))) |
| 231 | (hexlify-buffer) | 231 | (hexlify-buffer) |
| 232 | (set-buffer-modified-p modified)) | 232 | (restore-buffer-modified-p modified)) |
| 233 | (make-local-variable 'hexl-max-address) | 233 | (make-local-variable 'hexl-max-address) |
| 234 | (setq hexl-max-address max-address) | 234 | (setq hexl-max-address max-address) |
| 235 | (condition-case nil | 235 | (condition-case nil |
| @@ -300,9 +300,16 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode. | |||
| 300 | (lambda (string &optional bound noerror count) | 300 | (lambda (string &optional bound noerror count) |
| 301 | (funcall | 301 | (funcall |
| 302 | (if isearch-forward 're-search-forward 're-search-backward) | 302 | (if isearch-forward 're-search-forward 're-search-backward) |
| 303 | (if (> (length string) 80) | 303 | (let ((textre |
| 304 | (regexp-quote string) | 304 | (if (> (length string) 80) |
| 305 | (mapconcat 'string string "\\(?:\n\\(?:[:a-f0-9]+ \\)+ \\)?")) | 305 | (regexp-quote string) |
| 306 | (mapconcat (lambda (c) (regexp-quote (string c))) string | ||
| 307 | "\\(?:\n\\(?:[:a-f0-9]+ \\)+ \\)?")))) | ||
| 308 | (if (string-match "\\` ?\\([a-f0-9]+ \\)*[a-f0-9]+ ?\\'" string) | ||
| 309 | (concat textre "\\|" | ||
| 310 | (mapconcat 'regexp-quote (split-string string " ") | ||
| 311 | " \\(?: .+\n[a-f0-9]+: \\)?")) | ||
| 312 | textre)) | ||
| 306 | bound noerror count)) | 313 | bound noerror count)) |
| 307 | (let ((isearch-search-fun-function nil)) | 314 | (let ((isearch-search-fun-function nil)) |
| 308 | (isearch-search-fun)))) | 315 | (isearch-search-fun)))) |
| @@ -318,34 +325,33 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode. | |||
| 318 | "Save a hexl format buffer as binary in visited file if modified." | 325 | "Save a hexl format buffer as binary in visited file if modified." |
| 319 | (interactive) | 326 | (interactive) |
| 320 | (if hexl-in-save-buffer nil | 327 | (if hexl-in-save-buffer nil |
| 321 | (set-buffer-modified-p (if (buffer-modified-p) | 328 | (restore-buffer-modified-p |
| 322 | (save-excursion | 329 | (if (buffer-modified-p) |
| 323 | (let ((buf (generate-new-buffer " hexl")) | 330 | (let ((buf (generate-new-buffer " hexl")) |
| 324 | (name (buffer-name)) | 331 | (name (buffer-name)) |
| 325 | (file-name (buffer-file-name)) | 332 | (start (point-min)) |
| 326 | (start (point-min)) | 333 | (end (point-max)) |
| 327 | (end (point-max)) | 334 | modified) |
| 328 | modified) | 335 | (with-current-buffer buf |
| 329 | (set-buffer buf) | 336 | (insert-buffer-substring name start end) |
| 330 | (insert-buffer-substring name start end) | 337 | (set-buffer name) |
| 331 | (set-buffer name) | 338 | (dehexlify-buffer) |
| 332 | (dehexlify-buffer) | 339 | ;; Prevent infinite recursion. |
| 333 | ;; Prevent infinite recursion. | 340 | (let ((hexl-in-save-buffer t)) |
| 334 | (let ((hexl-in-save-buffer t)) | 341 | (save-buffer)) |
| 335 | (save-buffer)) | 342 | (setq modified (buffer-modified-p)) |
| 336 | (setq modified (buffer-modified-p)) | 343 | (delete-region (point-min) (point-max)) |
| 337 | (delete-region (point-min) (point-max)) | 344 | (insert-buffer-substring buf start end) |
| 338 | (insert-buffer-substring buf start end) | 345 | (kill-buffer buf) |
| 339 | (kill-buffer buf) | 346 | modified)) |
| 340 | modified)) | 347 | (message "(No changes need to be saved)") |
| 341 | (message "(No changes need to be saved)") | 348 | nil)) |
| 342 | nil)) | ||
| 343 | ;; Return t to indicate we have saved t | 349 | ;; Return t to indicate we have saved t |
| 344 | t)) | 350 | t)) |
| 345 | 351 | ||
| 346 | ;;;###autoload | 352 | ;;;###autoload |
| 347 | (defun hexl-find-file (filename) | 353 | (defun hexl-find-file (filename) |
| 348 | "Edit file FILENAME in hexl-mode. | 354 | "Edit file FILENAME in `hexl-mode'. |
| 349 | Switch to a buffer visiting file FILENAME, creating one in none exists." | 355 | Switch to a buffer visiting file FILENAME, creating one in none exists." |
| 350 | (interactive | 356 | (interactive |
| 351 | (list | 357 | (list |
| @@ -367,7 +373,7 @@ With arg, don't unhexlify buffer." | |||
| 367 | (original-point (1+ (hexl-current-address)))) | 373 | (original-point (1+ (hexl-current-address)))) |
| 368 | (dehexlify-buffer) | 374 | (dehexlify-buffer) |
| 369 | (remove-hook 'write-contents-functions 'hexl-save-buffer t) | 375 | (remove-hook 'write-contents-functions 'hexl-save-buffer t) |
| 370 | (set-buffer-modified-p modified) | 376 | (restore-buffer-modified-p modified) |
| 371 | (goto-char original-point) | 377 | (goto-char original-point) |
| 372 | ;; Maybe adjust point for the removed CR characters. | 378 | ;; Maybe adjust point for the removed CR characters. |
| 373 | (when (eq (coding-system-eol-type buffer-file-coding-system) 1) | 379 | (when (eq (coding-system-eol-type buffer-file-coding-system) 1) |
| @@ -403,7 +409,7 @@ Ask the user for confirmation." | |||
| 403 | (original-point (1+ (hexl-current-address)))) | 409 | (original-point (1+ (hexl-current-address)))) |
| 404 | (dehexlify-buffer) | 410 | (dehexlify-buffer) |
| 405 | (remove-hook 'write-contents-functions 'hexl-save-buffer t) | 411 | (remove-hook 'write-contents-functions 'hexl-save-buffer t) |
| 406 | (set-buffer-modified-p modified) | 412 | (restore-buffer-modified-p modified) |
| 407 | (goto-char original-point)))) | 413 | (goto-char original-point)))) |
| 408 | 414 | ||
| 409 | (defun hexl-current-address (&optional validate) | 415 | (defun hexl-current-address (&optional validate) |
| @@ -917,14 +923,14 @@ Customize the variable `hexl-follow-ascii' to disable this feature." | |||
| 917 | ))))) | 923 | ))))) |
| 918 | 924 | ||
| 919 | (defun hexl-activate-ruler () | 925 | (defun hexl-activate-ruler () |
| 920 | "Activate `ruler-mode'" | 926 | "Activate `ruler-mode'." |
| 921 | (require 'ruler-mode) | 927 | (require 'ruler-mode) |
| 922 | (set (make-local-variable 'ruler-mode-ruler-function) | 928 | (set (make-local-variable 'ruler-mode-ruler-function) |
| 923 | 'hexl-mode-ruler) | 929 | 'hexl-mode-ruler) |
| 924 | (ruler-mode 1)) | 930 | (ruler-mode 1)) |
| 925 | 931 | ||
| 926 | (defun hexl-follow-line () | 932 | (defun hexl-follow-line () |
| 927 | "Activate `hl-line-mode'" | 933 | "Activate `hl-line-mode'." |
| 928 | (require 'frame) | 934 | (require 'frame) |
| 929 | (require 'hl-line) | 935 | (require 'hl-line) |
| 930 | (with-no-warnings | 936 | (with-no-warnings |
| @@ -1071,5 +1077,5 @@ This function is assumed to be used as call back function for `hl-line-mode'." | |||
| 1071 | 1077 | ||
| 1072 | (provide 'hexl) | 1078 | (provide 'hexl) |
| 1073 | 1079 | ||
| 1074 | ;;; arch-tag: d5a7aa8a-9bce-480b-bcff-6c4c7ca5ea4a | 1080 | ;; arch-tag: d5a7aa8a-9bce-480b-bcff-6c4c7ca5ea4a |
| 1075 | ;;; hexl.el ends here | 1081 | ;;; hexl.el ends here |