Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The light of a hundred stars does not equal the light of the moon.


computers / comp.editors / Autosetting Tab-Expansion Mode

SubjectAuthor
o Autosetting Tab-Expansion ModeLawrence D'Oliveiro

1
Autosetting Tab-Expansion Mode

<utbdga$mrjn$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=240&group=comp.editors#240

  copy link   Newsgroups: comp.editors
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.editors
Subject: Autosetting Tab-Expansion Mode
Date: Tue, 19 Mar 2024 07:05:46 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <utbdga$mrjn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Mar 2024 07:05:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="cf2257effda993e7401c0124f815988b";
logging-data="749175"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gHPBJC2Yi19+Oss2c3P0w"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:wYtXbjTfVxmyUGpRQdZO62jDgbc=
 by: Lawrence D'Oliv - Tue, 19 Mar 2024 07:05 UTC

I have gone off putting tabs in source files; so I normally have
things set so that pressing the tab key inserts the right number of
spaces to take the position to the next tab stop.

However, when working with files from other sources that already have
tabs in them, it is handy to be able to remain compatible by having
the tab key insert a tab in those files, without any special checking
on my part.

Here is a hook for Emacs that automatically runs every time a file is
opened; it does a quick sniff around to see if it can spot any tabs,
and if it does, then it sets the tab key to insert a tab, otherwise it
sets it to insert spaces.

(add-hook 'find-file-hook
(lambda ()
"sets tab expansion depending on whether the current buffer contains tabs."
(save-excursion
; check text within the region of point; if tabs are found, then
; indent with tabs, else indent with spaces
(let
(
(checkamt 2048) ; how much text to check
)
(when (<= (point-max) (+ (point) checkamt))
(goto-char
(cond
((>= (point-max) checkamt)
(- (point-max) checkamt)
)
(t
(point-min)
)
) ; cond
) ; goto-char
) ; when
(setq indent-tabs-mode (search-forward "\t" (+ (point) checkamt) t))
) ; let
) ; save-excursion
) ; lambda
) ; add-hook


computers / comp.editors / Autosetting Tab-Expansion Mode

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor