2015-07-04

emacs bug: can't paste into emacs

emacs bug: can't paste into emacs

there's this bug that started to happen about a year ago. Emacs 24, and 25.

  • GNU bug report logs - #16737
  • From: Sujith Manoharan
  • Subject: 24.3.50; Yank causes hang
  • Date: Thu, 13 Feb 2014 09:10:55 +0530

Pasting content selected in a browser causes Emacs to hang completely sometimes. This is not consistently reproducible, but it happens after a few hours of usage, sometimes days.

from http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16737#17

This happens to me when i use xah-find-replace-text on few thousand files. 〔➤ Emacs Package: xah-find.el grep/sed in Pure Emacs Lisp

not always, but most of the time.

the number of files doesn't seem to matter. But what matters is likely the number of replacements.

there are 10 or so people wrote in that thread who also have the problem. But, a reproducible step is hard to get.

however, there's a reproduction steps described here


From: "Alan D. Salewski"
To: 16737 @ debbugs.gnu.org
Subject: Re: bug#16737: Timed out waiting for reply from selection owner
Date: Sun, 14 Jun 2015 23:00:34 -0400

The below cookbook works to reproduce the issue for me every time, so I
can now trigger the issue on-demand.

As noted in message #149 above[0], I'm running the
'emacs24-lucid-24.4+1-5' package on Debian GNU/Linux; x86_64; 4 core
Intel i7.

I'm running an X11 window manager (sawfish) with no clipboard manager.

To reproduce the issue:

    1. $ type -a emacs
       emacs is /usr/bin/emacs

       $ readlink -f /usr/bin/emacs
       /usr/bin/emacs24-lucid

       $ emacs -Q

       The "*scratch*" buffer is visible.

    2. M-x server-start

    3. In a terminal window (xterm in my case):

       $ emacsclient -t

       The "*scratch*" buffer is visible here, as well.

    4. Select a sizable bit of text to the X11 clipboard. A small amount
       of text won't trigger the issue, but I don't yet know what the
       boundary is. For my testing, I have a browser window open to
       this web page in iceweasel (firefox), and use the 'C-a' hotkey in
       that app followed by 'C-c' to select the full page of text:

           http://matt.might.net/articles/low-level-web-in-racket/

    5. In the emacsclient window in the terminal emulator, paste the
       text from the clipboard. I use the middle button on my 3-button
       mouse to do this.

    6. Back in iceweasel, select any small amount of text (~20 chars is
       fine) from the same page (again, using 'C-c').

    7. In the X11 emacs frame, position the mouse pointer over the
       blinking cursor and press the middle mouse button to attempt a
       "paste" operation (mouse-yank-primary).

       Emacs appears to hang for about 20 seconds, and then the "Timed
       out waiting for reply..." message appears.

The cookbook works not only with the stock Debian 'emacs24-lucid'
package, but also with that package compiled with different build time
options (-g, -O0, -DTRACE_SELECTION). The cookbook also works when I
build with random other debugging code compiled in (all based on the
Debian source package emacs24-24.4+1). It does not seem to be sensitive
to being set up "just right".

A slight variation of the above cookbook works with the stock 'emacs24'
Debian package (same version as the '*-lucid' package above), which is
the variation compiled to use gtk. For this version, the small amount of
text selected in step 6 above does not seem to trigger the issue, but
pasting the full amount of text from the web page does. So the cookbook
variation here is to simply skip step 6 (or replace it with step 4, if
some other process has become the X11 selction "owner"). When running
this version, the paste into the X11 emacs frame is preceeded by a pause
and CPU spiking to 100%, the same as indicated by other reports.

Once the issue has been triggered, no further "paste" operations will
work in any emacs X11 frame that is part of the same emacs process, at
least not without using gdb to jump over these lines in
x_get_foreign_selection (xselect.c):

1241    if (NILP (XCAR (reading_selection_reply)))
1242      error ("Timed out waiting for reply from selection owner");

Once those are jumped, the "paste" operation completes (the text shows
up on the buffer, as desired), but the state is still hosed.

Pasting into 'emacsclient -t' buffers running in terminal emulator
windows (xterm) does continue to work, though. So if somebody is truly
desperate to keep a given emacs process alive, keeping a terminal-based
emacsclient window handy as a target for paste operations could serve as
a workaround once the issue has been triggered.

Thanks,
-Al

[0] message #149
    http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16737#149

2015-06-21

computer languages = decades of backward compatibility cruft problem

computer languages have a major problem. That is, backward compatibility. Basically all languages, are hit with decades of backward compatibility cruft. And, that seems to the the main problem of languages.

so, how to solve this?

it seems, one way, is to somehow magically automatically change all existing code. When old code run, it automatically generates new code, and that source code is run. Βut this doesn't seem to solve the problem. Because the lang still holds all the old cruft. It only reduces the problem, by making it trivial to update code.

perhaps another way, is to declare, that the language will forever be unstable. That, by using the language, you assume to continuously update your code. Google's web products, seems to be taking this approach. (even though it's not languages, per se. But lots of Google's API are like that, and comes and go.)

2015-03-15

Google Code shutting down, future of ErgoEmacs

Google announced that they are going to shut down Google Code. See http://google-opensource.blogspot.com/2015/03/farewell-to-google-code.html

ErgoEmacs is hosted on Google Code. https://code.google.com/p/ergoemacs/. What to do?

ErgoEmacs started in 2008. The goal was to create a binary usable emacs for Microsoft Windows, Mac. Note: a binary, that anyone who never heard of emacs can download and immediatly be productive like a notepad. No tech talk, but dense tech info available for those who look. Not some “welcome to the powerful editor emacs you must have heard, welcome to the elite hacker commu, now git clone this and that and unix then make, and set env var bash linux and open source be with you happy hacking fuck”

Thanks to David Capello's work over the years, the Windows binary became a reality and served its purpose well for a number of years. However, Mac version never came about.

Since about 2012, ErgoEmacs became largely dormant. David got other things to do, and i also got busy with other things. I still work on lots elisp code, but the last Microsoft Windows binary is in .

During these years, a number of things has happened. Emacs now has a package system. So, installing third-party software becomes easier and coherent. (but still require experienced emacs knowledge and programer know-how.)

Matthew L Fidler, took over the ErgoEmacs keybinding part (aka “ergoemacs-mode”), which is the main part of ErgoEmacs. Matthew has brought ergoemacs-mode to a new level, and is now released as a independent package at https://ergoemacs.github.io/, and it's also made into FSF's Elpa repository, as well as on MELPA repository.

ergoemacs-mode is the bulk of ErgoEmacs.

So, now, what should we do with ErgoEmacs? I sure don't have time to lead in building binaries. A downloadable binary that people can use right away is still lacking in the emacs community. But, i can't do it.

I'm thinking, i'll just use Google's provided tool to “migrate” to github, and just leave it there. Since 2012 ErgoEmacs binary for Microsoft Windows might still be useful for some.

2015-02-06

Emacs Org Mode Bable bug. For emacs lisp, session is always on

Emacs Org Mode Bable bug. For emacs lisp, session is always on.

* test session; no session

#+BEGIN_SRC emacs-lisp :exports both
(setq x 3)
#+END_SRC

#+RESULTS:
: 3

#+BEGIN_SRC emacs-lisp :exports both
(+ 2 x)
#+END_SRC

#+RESULTS:
: 5

save the above as session-test.org, then open it, M-x org-mode. Move cursor to the elisp code block, press C-c C-c to eval. Repeat for the second block.

The expected result for second block should be error of unknown variable x.

2015-02-02

emacs: xah fly keys, harmless key maps

Global Bindings Starting With <menu> n:
key             binding
---             -------

<menu> n RET    Prefix Command
<menu> n SPC    Prefix Command
<menu> n 0      shell-command-on-region
<menu> n 1      set-input-method
<menu> n 2      global-hl-line-mode
<menu> n 3      whitespace-mode
<menu> n 4      linum-mode
<menu> n 5      visual-line-mode
<menu> n 6      calendar
<menu> n 7      calc
<menu> n 8      shell
<menu> n 9      shell-command
<menu> n a      text-scale-adjust
<menu> n b      toggle-debug-on-error
<menu> n c      toggle-case-fold-search
<menu> n d      narrow-to-page
<menu> n e      eshell
<menu> n f      Prefix Command
<menu> n g      toggle-frame-fullscreen
<menu> n h      widen
<menu> n i      make-frame-command
<menu> n n      narrow-to-region
<menu> n r      read-only-mode
<menu> n s      flyspell-buffer
<menu> n t      narrow-to-defun
<menu> n u      menu-bar-open
<menu> n w      eww

<menu> n SPC h  xah-toggle-read-novel-mode
<menu> n SPC n  xah-toggle-line-spacing
<menu> n SPC t  xah-toggle-margin-right

<menu> n f C-f  find-file-other-frame
<menu> n f C-o  display-buffer-other-frame
<menu> n f .    find-tag-other-frame
<menu> n f 0    delete-frame
<menu> n f 1    delete-other-frames
<menu> n f 2    make-frame-command
<menu> n f b    switch-to-buffer-other-frame
<menu> n f d    dired-other-frame
<menu> n f f    find-file-other-frame
<menu> n f m    compose-mail-other-frame
<menu> n f o    other-frame
<menu> n f r    find-file-read-only-other-frame

<menu> n RET F  set-file-name-coding-system
<menu> n RET X  set-next-selection-coding-system
<menu> n RET c  universal-coding-system-argument
<menu> n RET f  set-buffer-file-coding-system
<menu> n RET k  set-keyboard-coding-system
<menu> n RET l  set-language-environment
<menu> n RET p  set-buffer-process-coding-system
<menu> n RET r  revert-buffer-with-coding-system
<menu> n RET t  set-terminal-coding-system
<menu> n RET x  set-selection-coding-system

These are keys starting with 【▤ Menu n】 from xah fly keys Mode. This key set is for commands that are “harmless” — even if called accidentally. They usually do prompt or do some display changes, and never edit anything.

What's the Impetus that Made Lambda Calculus So Powerful?

what's lambda calculus? It's a notation, and nothing but syntax & notation.

The λ-calculus is, at heart, a simple notation for functions and application. The main ideas are applying a function to an argument and forming functions by abstraction. The syntax of basic λ-calculus is quite sparse, making it an elegant, focused notation for representing functions. Functions and arguments are on a par with one another. The result is an intensional theory of functions as rules of computation, contrasting with an extensional theory of functions as sets of ordered pairs. Despite its sparse syntax, the expressiveness and flexibility of the λ-calculus make it a cornucopia of logic and mathematics. This entry develops some of the central highlights of the field and prepares the reader for further study of the subject and its applications in philosophy, linguistics, computer science, and logic.

http://plato.stanford.edu/entries/lambda-calculus/

and that's why, syntax is the most important thing in languages. Programing Language Syntax Soup

2015-01-30

Clojure Support in emacs org-mode via nREPL/CIDER

Clojure Support in emacs org-mode via nREPL/CIDER

as you know, org-mode supports evaluating embedded source code of many languages. (that is, you can have many lang's code such as python in org file, then press a key to eval the code block and have the result embedded in the file (or just displayed), and when you export to HTML, you can also have it eval all source code and have result embedded in the doc.)

the current released version supports Clojure, but via SLIME, which is a engine for interaction with Common Lisp.

Using Clojure in emacs with SLIME is being obsoleted.

The good news is that, in the org-mode development version, it has a working version of clojure support with nREPL/CIDER.

goto http://orgmode.org/ and get the dev version.

basically, you just need to replace the old ob-clojure.el file with new.

how to use org mode's eval lang support? I'll have a article coming up. For now, you can read the official doc at http://orgmode.org/manual/Working-With-Source-Code.html#Working-With-Source-Code

if you don't know org mode basics, see Emacs: Writing Outline, org-mode Tutorial

Thanks to Bastien Guerry ( http://bzg.fr/ ), the current org-mode leader, and Eric Schulte ( http://www.cs.unm.edu/~eschulte/ ) who created the eval lang system in org-mode.

does md5 creates more randomness?

given a 32 digits hex number that is random enough. If i pass it thru md5, is the result more random or less?

few years back, i wrote a function to generate UUID, here: Emacs Lisp: Insert Random ID, Random UUID

I was simply calling random number function in emacs. Christopher Wellons improved it by first gather bunch of random info such as time, user's name, last keystroke typed, etc, then, feed it to md5, then basically use that result as UUID.

The question is, would that actually improve the function? That is, reduce the chances of generating the same UUID?

If you begin with random info such as time and user's last few keystrokes, then yes. But the step i don't quite understand is md5.

md5 takes arbitrary text and returns a 32 digits hexadecimal. Most or all other “hash function” do the same, that is, take a arbitrarily long or short text as input, and returns a fixed number of digits. But the interesting question is, such thing is mathematically impossible. Somewhat like a pigeon hole principle. You can never take many things and produce less things such that it is always unique for every input. The gist of “hash function” is about the impossibility of generating the input given the output. But, i don't know what's the uniqueness property.

2014-11-20

clojure problem: string not in core

string manipulation is the most important element in modern programing. This is the first thing you teach to beginners, about any language.

But with clojrue, it's not core part of the language. You need to load it as a lib, or, go use Java's string stuff.

Try to tell that to beginner. You either face the immense complexity of clojure namespace , or the immense complexity of dealing with a entire complexity bag the interoperation with Java.

PS: actually, just prefix the namespace. ⁖ (clojure.string/upper-case "xyz").

2014-11-19

One Weird Annoyance About Clojure: Java

one annoying thing about Clojure is that it runs on Java Virtual Machine. Clojure is actually a so-called hosted language, and this is by spec. (and JavaScript is a hosted language too. 〔➤ JavaScript Tutorial: Understand JavaScript in Depth〕).

This practically means is that, Clojure isn't a “fixed” language. For example, when it's running on JVM, its regex is Java syntax, its string functions are Java language's string methods. When it runs in JavaScript world (as ClojureScript do), its regex is JavaScript's regex. 〔➤ JavaScript Regex Syntax

But, that's not all. The MOST annoying thing is that, you actually need to know a lot about stinking Java in order to do any real world work with Clojure. (don't let any hacker type fanatics tell you otherwise) You need to know Java class/object system, its package system, its namespace scheme, Java Virtual Machine system, its compilation cycle, its tools and achive files. Even the official Clojure documentation, outright simply say things like “returns a Java xyz object.” with no further explanation, in lots of places.

it is not to be taken lightly, that when you learn Clojure, you actally need to gradually understand a lot about Java ecosystem too.

but at least, thank god, it's a lisp that has industrial value, and is a Java replacement.