tag:blogger.com,1999:blog-42764770447253242952024-02-08T15:32:53.580+02:00Brain break (en).it/security/free/math/sci/music
<p>
English version of <a href="http://brain-break-ru.blogspot.com">brain-break-ru.blogspot.com</a>. Enjoy!</p>gavenkoahttp://www.blogger.com/profile/04788714574575512630noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-4276477044725324295.post-80615870429910053362010-08-17T00:20:00.004+03:002010-12-21T22:26:38.941+02:00Determining running environment and platform capabilities in Emacs.<style type="text/css">
div#code {
border: dotted 1px #cccccc;
background: #fffff0;
width: 95%; overflow: auto;
line-height: 1em;
margin: 5px; padding: 5px;
white-space: pre; font-family: monospace;
}
</style>
To proper work on different Emacs releases and on different platforms large/complex <code>.emacs</code> config file must check certain condition.
<p>
I collect come of them and by this post make it public.
<a name='more'></a>
<p>
So check variables:
<div id="code"> emacs-major-version
emacs-minor-version
window-system - 'nil' if in terminal, 'w32' if native Windows build, 'x' if under X Window
window-system-version - for windows only
operating-system-release - release of the operating system Emacs is running on
system-configuration - like configuration triplet: cpu-manufacturer-os
system-name - host name of the machine you are running on
system-time-locale
system-type - indicating the type of operating system you are using:
'gnu' (GNU Hurd), 'gnu/linux', 'gnu/kfreebsd' (FreeBSD),
'darwin' (GNU-Darwin, Mac OS X), 'ms-dos', 'windows-nt', 'cygwin'
system-uses-terminfo
window-size-fixed
</div>
and check functions:
<div id="code"> (fboundp ...) - return t if SYMBOL's function definition is not void
(featurep ...) - returns t if FEATURE is present in this Emacs
(display-graphic-p) - return non-nil if DISPLAY is a graphic display; graphical
displays are those which are capable of displaying several
frames and several different fonts at once
(display-multi-font-p) - same as 'display-graphic-p'
(display-multi-frame-p) - same as 'display-graphic-p'
(display-color-p) - return t if DISPLAY supports color
(display-images-p) - return non-nil if DISPLAY can display images
(display-grayscale-p) - return non-nil if frames on DISPLAY can display shades of gray
(display-mouse-p) - return non-nil if DISPLAY has a mouse available
(display-popup-menus-p) - return non-nil if popup menus are supported on DISPLAY
(display-selections-p) - return non-nil if DISPLAY supports selections
</div>
Run those checks as below:
<div id="code">
(when window-system ...)
(when (eq window-system 'x) ...)
(when (>= emacs-major-version 22) ...)
(when (fboundp '...) ...)
(when (featurep '...) ...)
</div>gavenkoahttp://www.blogger.com/profile/04788714574575512630noreply@blogger.comtag:blogger.com,1999:blog-4276477044725324295.post-22234889537377478962010-03-07T14:15:00.005+02:002010-03-07T14:25:14.393+02:00emacs.info under DebianBecause of Debian policy documentation covered by FDL license with invariant sections is not allowed in packets repository tree. So it must be installed manually.
<div class="fullpost">
<p>
You can set <code>INFOPATH</code> env var in your <code>~/.profile</code>, but I done this in .emacs in such way:
<div id=code>;; Because of Debian policy documentation covered by FDL license
;; with invariant sections is not allowed in packets
;; repository tree. So it must be installed manually.
;; My usual configuration is install user local software
;; into ~/usr DISTDIR.
(unless (getenv "INFOPATH")
(setenv "INFOPATH" "~/usr/share/info:"))
</div>
<p>
This code also useful as manually builded software I configure like this:
<div id=code> $ configure --prefix=$HOME/use</div>
so their info documentation automatically become available in Emacs Info system.
<p>
<ul>
<li><a href="http://www.gnu.org/copyleft/fdl.html">FDL text on gnu.org</a>
<li><a href="http://en.wikipedia.org/wiki/GNU_Free_Documentation_License">http://en.wikipedia.org/wiki/GNU_Free_Documentation_License</a>
</ul>
</div>gavenkoahttp://www.blogger.com/profile/04788714574575512630noreply@blogger.comtag:blogger.com,1999:blog-4276477044725324295.post-81178582139836703272009-10-11T21:39:00.006+03:002012-08-10T15:53:51.642+03:00Sort and uniquify lines in Emacs.For only sort lines exist built-in func: <code>C-x sort-lines</code>.
<p>
Sort and uniquify lines:
<ul>
<li>select region
<li><code>C-u M-| sort -u RET</code>
</ul>
<p>
With <code>transient-mark-mode</code> and <code>delete-selection-mode</code> enabled:
<ul>
<li>select region
<li><code>M-| sort -u RET</code>
</ul>
to replace selection with sorted and uniquified lines.gavenkoahttp://www.blogger.com/profile/04788714574575512630noreply@blogger.comtag:blogger.com,1999:blog-4276477044725324295.post-73224713976664046472009-08-20T23:17:00.010+03:002010-12-21T22:28:28.069+02:00Switching from Gnu Emacs 22.x to 23.1 on Windows.When moving from GNU Emacs 22.x to GNU Emacs 23.1 I get only two trubles.
<a name='more'></a>
<p>
Firstly I get error message:
<div id="code">error: The directory e:/home/.emacs.d/server is unsafe
</div>
when run <code>(server-start)</code>.
Problem placed in function <code>server-ensure-safe-dir</code>:
<div id="code"> (unless (and (eq t (car attrs)) <span style="color:red;">(eql (nth 2 attrs) (user-uid))</span>
(or (eq system-type 'windows-nt)
(zerop (logand ?\077 (file-modes dir)))))
(error "The directory %s is unsafe" dir))))
</div>
Solusion found on <a href="http://stackoverflow.com/questions/885793/emacs-error-when-calling-server-start">stackoverflow.com</a>. You must delete higlighted code and update correcponding bytecode (Emacs firstly search for .elc files and then for .el, so edit <code>emacs-23.1/lisp/server.el</code> and type C-x byte-compile-file <Down> <Ret>).
<p>
Seconf problem occur with deprication of <code>codepage-setup</code> function (no longer in distributive). Now you dont need call codepage-setup to work with IBM cpXXX codepages! For compatibility with old Emacs versions put (or replace old) in your .emacs such code:
<div id="code">(when (<= emacs-major-version 22)
(codepage-setup 866)
(codepage-setup 1251)
)
</div>
<p>
Announce of GNU Emacs 23.1 release:
<a href="http://groups.google.com/group/gnu.emacs.announce/browse_thread/thread/c8ae7b91dc61c454#">groups.google.com</a>
<p>
<b>Update: 2010-03-17.</b>
<p>
2009-09-19 fixed bug #4197 about <code>server-ensure-safe-dir</code>. From ChangeLog:
<div id=code>This fixes bug#4197 (merged to bug#865, though not identical).
* server.el (server-auth-dir): Add docstring note about FAT32.
(server-ensure-safe-dir): Accept FAT32 directories as "safe",
but warn against using them.
</div>
<p>
Also I found another workaround:
<div id=code>(require 'server)
(when (and (= emacs-major-version 23) (= emacs-minor-version 1) (equal window-system 'w32))
(defun server-ensure-safe-dir (dir) "Noop" t)) ; Suppress error directory ~/.emacs.d/server is unsafe on windows.
(server-start)</div>
<p>
<b>Update: 2010-03-19.</b>
<p>
Also see discussion on <a href="http://stackoverflow.com/questions/885793/emacs-error-when-calling-server-start/1566618#1566618">stackoverflow.com</a>.gavenkoahttp://www.blogger.com/profile/04788714574575512630noreply@blogger.com