aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2020-07-25 13:17:41 +0200
committerOmar Polo <op@omarpolo.com>2020-07-25 13:17:41 +0200
commit9537b3871a2c19ce204f314c1bb8bbe2de045e1f (patch)
treed1a2f3d97a21c63e9a11607ccf4521da12190ead
parent040225433437ec43873305eaf8a55515cd58cab0 (diff)
downloadsam.el-9537b3871a2c19ce204f314c1bb8bbe2de045e1f.tar.gz
sam.el-9537b3871a2c19ce204f314c1bb8bbe2de045e1f.tar.bz2
improved output of position if (= begin end)
-rw-r--r--sam.el14
1 files changed, 9 insertions, 5 deletions
diff --git a/sam.el b/sam.el
index faacf59..3ef3bfc 100644
--- a/sam.el
+++ b/sam.el
@@ -185,13 +185,17 @@
(defun sam-cmd-charoffset (_arg)
(cl-destructuring-bind (begin . end) (sam-current-buffer-region)
(with-current-buffer (sam-get-buffer)
- (insert "#" (number-to-string begin) ","
- "#" (number-to-string end) "\n"))))
+ (if (= begin end)
+ (insert "#" (number-to-string begin) "\n")
+ (insert "#" (number-to-string begin) ","
+ "#" (number-to-string end) "\n")))))
(defun sam-cmd-linenum (_arg)
- (let ((p (sam-current-buffer-region)))
- (cl-destructuring-bind (begin . end) p
- (with-current-buffer (sam-get-buffer)
+ (cl-destructuring-bind (begin . end) (sam-current-buffer-region)
+ (with-current-buffer (sam-get-buffer)
+ (if (= begin end)
+ (insert (number-to-string (line-number-at-pos begin)) "; "
+ "#" (number-to-string begin) "\n")
(insert (number-to-string (line-number-at-pos begin)) ","
(number-to-string (line-number-at-pos end)) "; "
"#" (number-to-string begin) ","