[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Closures in Emacs and their usage scenarios.
From: |
Emanuel Berg |
Subject: |
Re: Closures in Emacs and their usage scenarios. |
Date: |
Wed, 29 Sep 2021 08:43:05 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> Here is one example - note that the byte-compiler will warn
> that "the function ‘align-from-left’ is not known to be
> defined." Well, OK.
I think you can shut the byte-compiler up by using
`declare-function', see the source.
Is this the rare case of a mutable variable BTW?
Interesting if so, since it is the only use case I can think
of, maybe except for several functions sharing the same data
(OK, let's say that data won't change).
;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;; https://dataswamp.org/~incal/emacs-init/align-from-left.el
(require 'cl-lib)
(let ((alf-regexp))
(defun align-from-left (&optional set-regexp)
(interactive "p")
(let ((default-regexp "^\\|[[:punct:]]\\|[[:space:]][[:alnum:]]"))
(unless (stringp set-regexp)
(cl-case set-regexp
( 4 (setq alf-regexp (read-regexp "regexp: ")))
(16 (setq alf-regexp default-regexp))
( t (unless alf-regexp
(setq alf-regexp default-regexp) )))))
(let ((beg (point))
(re (or (and (stringp set-regexp) set-regexp)
alf-regexp) ))
(when (re-search-backward re (line-beginning-position) t)
(while (looking-at "[[:space:]]")
(forward-char 1) )
(insert (make-string (- beg (point)) ?\s)) ))))
(declare-function align-from-left nil)
(defalias 'alf #'align-from-left)
(provide 'align-from-left)
--
underground experts united
https://dataswamp.org/~incal
- Re: Closures in Emacs and their usage scenarios., (continued)
- Re: Closures in Emacs and their usage scenarios., Emanuel Berg, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., Hongyi Zhao, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., tomas, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., Hongyi Zhao, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., Emanuel Berg, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., Emanuel Berg, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., tomas, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., Hongyi Zhao, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., tomas, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., Emanuel Berg, 2021/09/29
Re: Closures in Emacs and their usage scenarios.,
Emanuel Berg <=
Re: Closures in Emacs and their usage scenarios., Stefan Monnier, 2021/09/27
- RE: [External] : Re: Closures in Emacs and their usage scenarios., Drew Adams, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., Arthur Miller, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., Hongyi Zhao, 2021/09/28
- Re: Closures in Emacs and their usage scenarios., Stefan Monnier, 2021/09/29
- Re: Closures in Emacs and their usage scenarios., Tomas Hlavaty, 2021/09/29
- Re: Closures in Emacs and their usage scenarios., Stefan Monnier, 2021/09/29
- Re: Closures in Emacs and their usage scenarios., Tomas Hlavaty, 2021/09/29
- RE: [External] : Re: Closures in Emacs and their usage scenarios., Drew Adams, 2021/09/29