[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/nhexl-mode 9549cf5 21/23: * packages/nhexl-mode/nhexl-m
From: |
Stefan Monnier |
Subject: |
[elpa] externals/nhexl-mode 9549cf5 21/23: * packages/nhexl-mode/nhexl-mode.el (nhexl-separate-line): New user config |
Date: |
Sat, 28 Nov 2020 18:35:46 -0500 (EST) |
branch: externals/nhexl-mode
commit 9549cf514cf8f7d3be54e3f9b13acf370901bfae
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* packages/nhexl-mode/nhexl-mode.el (nhexl-separate-line): New user config
(nhexl--make-line, nhexl--jit, nhexl--header-line): Obey it.
(nhexl-mode): Better take advantage of new window-size-change-functions.
---
nhexl-mode.el | 64 ++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 44 insertions(+), 20 deletions(-)
diff --git a/nhexl-mode.el b/nhexl-mode.el
index fdd9866..220b6a5 100644
--- a/nhexl-mode.el
+++ b/nhexl-mode.el
@@ -4,7 +4,7 @@
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
;; Keywords: data
-;; Version: 1.3
+;; Version: 1.4
;; Package-Requires: ((emacs "24.4") (cl-lib "0.5"))
;; This program is free software; you can redistribute it and/or modify
@@ -112,6 +112,12 @@ Otherwise they are applied unconditionally."
Groups are separated by spaces."
:type 'integer)
+(defcustom nhexl-separate-line nil
+ ;; FIXME: This var is not taken into account when auto-sizing the
+ ;; line-width!
+ "If non-nil, put the ascii area below the hex, on a separate line."
+ :type 'boolean)
+
(defvar nhexl--display-table
(let ((dt (make-display-table)))
(unless nhexl-display-unprintables
@@ -380,9 +386,11 @@ existing text, if needed with
`nhexl-overwrite-clear-byte'."
(jit-lock-unregister #'nhexl--jit)
(remove-hook 'after-change-functions #'nhexl--change-function 'local)
(remove-hook 'post-command-hook #'nhexl--post-command 'local)
- (remove-hook 'window-configuration-change-hook
- #'nhexl--window-config-change t)
- (remove-hook 'window-size-change-functions #'nhexl--window-size-change)
+ (if (>= emacs-major-version 27)
+ (remove-hook 'window-size-change-functions
#'nhexl--window-size-change t)
+ (remove-hook 'window-configuration-change-hook
+ #'nhexl--window-config-change t)
+ (remove-hook 'window-size-change-functions
#'nhexl--window-size-change))
(remove-function (local 'isearch-search-fun-function)
#'nhexl--isearch-search-fun)
;; FIXME: This conflicts with any other use of `display'.
@@ -420,11 +428,11 @@ existing text, if needed with
`nhexl-overwrite-clear-byte'."
(add-hook 'change-major-mode-hook (lambda () (nhexl-mode -1)) nil 'local)
(add-hook 'post-command-hook #'nhexl--post-command nil 'local)
(add-hook 'after-change-functions #'nhexl--change-function nil 'local)
- (add-hook 'window-configuration-change-hook
- #'nhexl--window-config-change nil 'local)
- (add-hook 'window-size-change-functions #'nhexl--window-size-change
- ;; Make it local in Emacsā„27
- nil (boundp 'window-buffer-change-functions))
+ (if (>= emacs-major-version 27)
+ (add-hook 'window-size-change-functions #'nhexl--window-size-change
nil t)
+ (add-hook 'window-configuration-change-hook
+ #'nhexl--window-config-change nil 'local)
+ (add-hook 'window-size-change-functions #'nhexl--window-size-change))
(add-function :around (local 'isearch-search-fun-function)
#'nhexl--isearch-search-fun)
;; FIXME: We should delay this to after running the minor-mode hook.
@@ -676,11 +684,15 @@ Return the corresponding nibble, if applicable."
(make-string (+ (/ (1+ (- next nextpos)) nhexl-group-size)
(* (- next nextpos) 2))
?\s))
- (propertize " " 'display
- `(space :align-to
- ,(+ (* lw 2) ;digits
- (/ lw nhexl-group-size) ;spaces
- 12 3)))))) ;addr + borders
+ (if nhexl-separate-line
+ (concat "\n"
+ (propertize " " 'display
+ `(space :align-to 12)))
+ (propertize " " 'display
+ `(space :align-to
+ ,(+ (* lw 2) ;digits
+ (/ lw nhexl-group-size) ;spaces
+ 12 3))))))) ;addr + borders
(font-lock-append-text-property 0 (length s) prop 'default s)
;; If the first char of the text has a button (e.g. it's part of
;; a hyperlink), clicking in the hex part of the display might signal
@@ -723,6 +735,16 @@ Return the corresponding nibble, if applicable."
(ol (make-overlay from next))
(s (nhexl--make-line from next zero nhexl--point))
(c (char-before next)))
+ (when nhexl-separate-line
+ (dotimes (i (- (min (point-max) next) from 1))
+ (let ((ol (make-overlay (+ from i) (+ from i 1))))
+ (overlay-put ol 'nhexl t)
+ (overlay-put ol 'after-string
+ (propertize " " 'display
+ `(space :align-to
+ ,(+ (* (1+ i) 2)
;digits
+ (/ (1+ i) nhexl-group-size)
;spaces
+ 12)))))))
(unless (or nhexl--put-LF-in-string (>= next (point-max)))
;; Display tables aren't applied to strings in `display' properties,
;; so we have to mimick it by hand.
@@ -803,12 +825,14 @@ Return the corresponding nibble, if applicable."
12))))))) ;addr
text
"")
- (propertize " " 'display
- `(space :align-to
- ,(+ (* lw 2) ;digits
- (/ lw nhexl-group-size) ;spaces
- 12 3))) ;addr + border
- text)))
+ (unless nhexl-separate-line
+ (concat
+ (propertize " " 'display
+ `(space :align-to
+ ,(+ (* lw 2) ;digits
+ (/ lw nhexl-group-size) ;spaces
+ 12 3))) ;addr + border
+ text)))))
(defun nhexl--post-command ()
- [elpa] externals/nhexl-mode 5ae7dc1 07/23: * nhexl-mode.el (nhexl-overwrite-only-mode): New minor mode., (continued)
- [elpa] externals/nhexl-mode 5ae7dc1 07/23: * nhexl-mode.el (nhexl-overwrite-only-mode): New minor mode., Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode 4ec0242 08/23: * nhexl-mode.el: Bump version number for new release, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode 25704c9 10/23: * nhexl-mode/nhexl-mode.el: Let isearch look for addresses as well, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode 16b716f 03/23: nhexl-mode.el: Fix last change., Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode e2450fd 09/23: * nhexl-mode.el: Hide undisplayable chars by default, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode 1082cc6 12/23: * nhexl-mode/nhexl-mode.el: Fix minor issues, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode 8310ad1 13/23: * nhexl-mode/nhexl-mode.el: Improve multi-window behavior, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode 1cb2581 14/23: * nhexl-mode/nhexl-mode.el: Get rid of the spurious top empty line, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode 42110aa 16/23: * nhexl-mode.el: Improve handling of mouse events, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode fa39048 17/23: * nhexl-mode.el: Add isearch and highlight to hex area, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode 9549cf5 21/23: * packages/nhexl-mode/nhexl-mode.el (nhexl-separate-line): New user config,
Stefan Monnier <=
- [elpa] externals/nhexl-mode ec80692 22/23: * packages/nhexl-mode/nhexl-mode.el (nhexl-mode-map): Remap EOL/BOL, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode 903f1b6 23/23: * .gitignore: New file, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode 6c31e4e 15/23: * nhexl-mode.el: Make C-u use hexadecimal, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode d8fa839 18/23: * nhexl-mode/nhexl-mode.el: Fix performance bug#33708, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode c0dac99 20/23: * packages/nhexl-mode/nhexl-mode.el (nhexl-group-size): New user config, Stefan Monnier, 2020/11/28
- [elpa] externals/nhexl-mode 630f003 19/23: * nhexl-mode.el (nhexl-nibble-self-insert): Obey overwrite-mode, Stefan Monnier, 2020/11/28