[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
window-other.el / ref-lines.el
From: |
Emanuel Berg |
Subject: |
window-other.el / ref-lines.el |
Date: |
Sun, 15 Jan 2023 14:11:50 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
(Pst, I don't know if "with other window" is a good idea,
anyway it should then be called IN other window ... BTW, what
does this (declare (indent 1) (debug t)) do?)
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/window-other.el
(defun next-window-buffer ()
(window-buffer (next-window)) )
(defmacro with-other-window (&rest body)
(declare (indent 1) (debug t))
`(let ((buf (next-window-buffer)))
(when (bufferp buf)
(with-current-buffer buf
,@body) )))
(defun apply-in-other-window (fn &rest args)
(let ((buf (next-window-buffer)))
(when (bufferp buf)
(with-current-buffer buf
(apply fn args) ))))
(provide 'window-other)
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/ref-lines.el
(require 'window-other)
(defun ref-lines-ref ()
(pcase-let ((`(,beg ,end) (if (use-region-p)
(list (line-number-at-pos (region-beginning))
(line-number-at-pos (region-end)) )
(list (line-number-at-pos) nil) )))
(if (and end (< beg end))
(format "lines %d-%d" beg end)
(format "line %d" beg) )))
(defun ref-lines (&optional other-win no-insert)
(interactive "P")
(let ((ref (if other-win
(apply-in-other-window #'ref-lines-ref)
(ref-lines-ref) )))
(when ref
(if no-insert
(prog1
ref
(message ref) )
(insert ref) ))))
--
underground experts united
https://dataswamp.org/~incal
- window-other.el / ref-lines.el,
Emanuel Berg <=