texts: Preventing mouse clicks in inactive windows from repositioning the cursor

texts:
When I have Emacs (24.4, Mac OS, NS build) in the foreground, I often have many windows open in one frame. I sometimes want to switch windows by clicking in an inactive window. By default, this calls mouse-set-point which (1) activates the window I clicked in, and (2) repositions the point to wherever I clicked. I want to change this behavior so clicking in an inactive window would only activate it, but not move the cursor. If I'm in an active window, I want it to reposition the cursor to wherever I clicked.

Is there any reasonable way built into Emacs to do this?

Edit 1: I just tried this:

(defadvice mouse-set-point (around cv/mouse-set-point (event) activate)
  (let ((event-target-window (caadr event)))
    (if (eql event-target-window (frame-selected-window))
        ad-do-it
      (set-frame-selected-window nil event-target-window))))

That doesn't work because mouse-set-point seems to fire in the new window to position itself.

Edit 2: Updated attempt:

(defadvice mouse-set-point (around cv/mouse-set-point (event) activate)
  (let ((event-name (car event))
        (event-target-window (caadr event)))
    (if (and (eql 'down-mouse-1 event-name)
             (eql event-target-window (frame-selected-window)))
        ad-do-it
      (set-frame-selected-window nil event-target-window))))

This does not work in a weird way. When I click above the cursor position in the inactive window, it does what I want. When I click below the cursor position the inactive window, it moves the cursor. Two events fire consistently: down-mouse-1 and then mouse-1. Both call mouse-set-point.

Edit 3: Replacing mouse-set-point does work, provided I also unset [down-mouse-1] (normally bound to mouse-drag-region):

(defun mouse-set-point-2 (event)
  (interactive "e")
  (mouse-minibuffer-check event)
  (let ((event-target-window (caadr event)))
    (if (eql event-target-window (frame-selected-window))
        (posn-set-point (event-end event))
      (set-frame-selected-window nil event-target-window))))

(global-set-key [mouse-1] 'mouse-set-point-2)

(global-unset-key [down-mouse-1])

Not good enough, I don't want to lose drag-selection with the mouse.

Edit 4: Adding advice to both mouse-set-point and mouse-drag-region seems to work.


texts: projectile-find-file and ivy - create file with subdirectories

texts:
I'm using ivy and projectile.

When I search for some file with projectile-find-file, and the file does not exist, I would it to be created.

If it is inside directories that also do not exist, ask if create those directories.

How to do that?

I found that some old code for helm https://www.reddit.com/r/emacs/comments/3m8i5r/helmprojectile_quickly_findcreate_new_file_in/

and that it's already commited https://github.com/bbatsov/helm-projectile/commit/1f0dc42645f006e925718785b9abc6991b7ce2c4.

I have such function for find-file:

(defun my-create-non-existent-directory ()
      (let ((parent-directory (file-name-directory buffer-file-name)))
        (when (and (not (file-exists-p parent-directory))
                   (y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory)))
          (make-directory parent-directory t))
          ;; wait until directory is created
          (while (not (file-directory-p parent-directory))
              (sleep-for 1)))
          ;; https://stackoverflow.com/questions/2592095/how-do-i-create-an-empty-file-in-emacs/11990694#11990694
          (shell-command (concat "touch " (shell-quote-argument (buffer-file-name)))))

(add-to-list 'find-file-not-found-functions #'my-create-non-existent-directory)


texts: how to tell org mode to make subsequent lines children of the hierarchy

texts:
I have a list like this:

remember to undo:
product 0 discrimination
limit(100)
ENV['MANUAL_...']

When point is at the beginning of line 1, how can I tell org mode
to make subsequent lines children of the hierarchy, like this

remember to undo:
  product 0 discrimination
  limit(100)
  ENV['MANUAL_...']

I don't even mind this

remember to undo:
  - product 0 discrimination
  - limit(100)
  - ENV['MANUAL_...']

or this

remember to undo:
  [ ] product 0 discrimination
  [ ] limit(100)
  [ ] ENV['MANUAL_...']

or even asterisks


texts: How to search the Emacs Lisp Reference Manual?

texts: Sometimes describe- or apropos- are not enough. How can I search the Emacs Lisp Reference Manual (C-h i m elisp) from within emacs?


texts: How do I capitalize the first words of sentences in some buffer text?

texts:
I know how to convert a string to upper case, to lower case, or to title case.

But the operation I do most frequently writing English text is to fix up capitalization so a sentence or group of sentences is in title case. That is, the first letter is capitalized and usually nothing else is, like the sentence you’re reading right now.

Is there an Emacs command or package to reformat a sentence in sentence case?


texts: How to Self Insert Tab When Editing String In go-mode?

texts:
The title contains the crux of my question. In go-mode, tabs and auto-indentation generally works well, except when I am editing strings.

When inside of a string, I'd like the tab key to self-insert. Right now, it does nothing.


texts: Yasnippets gives an unclear error (with example snippet)

texts:
I have the following snippet for PHP-mode, called Public.

#contributor : ReneFroger
#name : snippet for public
# --

# --------------------------------------------------
#  Method f${2:name}.
# --------------------------------------------------
/* R.F: $1

When I load the snippet into the buffer with PHP-mode, and I type a long sentence (the sentence is longer than the lines (----) as above). Then I get an error message from Yasnippet in another buffer:

  Warning (yasnippet): Couldn’t find: "[[:space:] ]#[[:space:]
  ]--------------------------------------------------[[:space:]
  ]*#[[:space:] ]*Method[[:space:] ]fname\.[[:space:] ]#[[:space:]
  ]--------------------------------------------------[[:space:]
  ]/\*[[:space:] ]R\.F:[[:space:] ]\(\)[[:space:]
  ]*This[[:space:] ]*is[[:space:] ]*an[[:space:] ]*error[[:space:]
  ]*that[[:space:] ]*gives[[:space:] ]*a[[:space:] ]*weird[[:space:]
  ]*error[[:space:] ]*in[[:space:] ]*Yasnippet[[:space:]
  ]*with[[:space:] ]unclear" Warning (yasnippet): Couldn’t find:
  "[[:space:] ]#[[:space:]

Before the regular packages update from Melpa (with Yasnippet included), I used this snippet a lot of time and never got this kind of error message.

It seems when entering a space, cause an error with Yasnippet. I googled around, but I couldn't find any explanation why spaces gives troubles with Yasnippet.

Anyone feeling to try this?


texts:
When I pull 25.1 down from FTP and configure using the following (extrapolated from this run):

curl -o "/tmp/emacs-25.1.tar.xz" "https://ftp.gnu.org/gnu/emacs/emacs-25.1.tar.xz"
tar xf "/tmp/emacs-25.1.tar.xz" -C /tmp
cd /tmp/emacs-25.1
./configure --prefix=/Users/travis/emacs --with-ns --with-modules
make
sudo make install

it's actually seems to be configuring without the --prefix.  I'm basing that assumption off

There's nothing in the prefix dir after make install.
There's still stuff in /tmp/emacs-25.1/.

So, I think to myself, 'no big deal, I'll just copy /tmp/emacs-25.1/ to /home/travis/emacs myself' – but that's a no-go.

Copying everything back into /tmp/emacs-25.1 does work, but it's bordering on too hacky.

Why isn't --prefix being respected?  Do I misunderstand its purpose?  This seems to apply across the board for macOS builds regardless of version.


texts: `Warning (bytecomp)` is a bit vague - can I get any more information?

texts:
When I start emacs, I get a couple of byte compilation warnings in a window that pops up:

Warning (bytecomp): `interactive-p' is an obsolete function (as of 23.2); use `called-interactively-p' instead. [7 times]
Warning (bytecomp): Use `with-current-buffer' rather than save-excursion+set-buffer

Can I get emacs to give me locations?


texts: How do I set a different location for the dot emacs .emacs file on Windows 7?

texts: I am using a Windows 7 computer and do not have administrator access. Therefore I can not place a dot emacs file in the root directory. Is there a way for me to specify a different location for the dot emacs file?


texts: Why Jupyter console sometimes decide to output sometimes don't?

texts:
Problem

I don't know why my Jupyter console sometimes doesn't output anything. An example is this:

Notice that only the first line gets its output. I use C-enter to execute each line. Line 2, 3, 4, 5 are just "silent". Especially line 5, shouldn't it be the same as line 1?
Setup

Here is my elpy config screen:


texts: Undecorated Frame with header line as titlebar

texts:
I am trying to remove all window manager decorations from emacs. This works well using:
(set-frame-parameter nil 'undecorated t)

But now what I want to have is a one line (global) header line (which spans across the entire frame) which acts like a title bar. Where I can drag the frame and resize it and so on.
(set-frame-parameter nil 'drag-with-header-line t)

Works to make the header line draggable. But I so far was only able to get a separate header line for each window. But I want one global one. Also I did not find out a way to resize the frame.
Any way to do this?


texts:
I have just started using emacs, so I decided to use cua-mode. I got this weird problem when I'm using macros and copy/cut (C-c/ C-x).

let's assume this simple macro for example: <F3> C-S-right C-c C-v <F4> When I execute it I'm getting this message: After 0 kbd macro iterations: keyboard macro terminated by a command ringing the bell

After some digging I found this at the recording (C-x C-k C-e): Macro:

<C-S-right>
C-c C-c <============== C-c twice!!!!
<timeout>
C-v ;; yank

I think the problem is the second C-c. When I remove the second C-c the macro works as expected. More info from C-h l (after making the macro):

<f3> [kmacro-start-macro-or-insert-counter]
<C-S-right> [right-word]
C-c [cua--prefix-override-handler]
C-c <timeout> [cua-copy-region]
C-v [cua-paste]
<f4> [kmacro-end-or-call-macro]

I'm guessing that I'm not the first one who uses cua-mode and macro, but I didn't found anything on it :(.

How do I fix this problem?

Stop using cua-mode is not an option of me right now.


texts: How can I add list arguments to key value pairs to defmacro?

texts:
I'm trying to use rg.
There is this explanation here:
(defmacro rg-define-search (name &rest args)
  "Define an rg search functions named NAME.
ARGS is a search specification that defines parameters of a search.
It optionally starts with a string that is used as the docstring for
the defined function.  The rest of ARGS contains key value pairs
according to the specification below.  All keys are optional with
specified default if left out.
---
:flags      `ask' or a list of command line flags that will be used when
            invoking the search.
---

I would like to add list with arguments as value to key :flags, but can't do it programmatically:
(setq aaa ("-z" "--context=4"))

(rg-define-search rg-treemacs
  "Search the current-file"
  :dir (f-dirname buffer-file-name)
  ;; :flags ("-z" "--context=4") ;; <-- works fine
  :flags aaa
  :files (f-filename buffer-file-name)
  :menu ("Custom" "L" "lisp"))
(rg-treemacs "aaa")

This gives an error:
(wrong-type-argument listp aaa)

So how can I do it?


texts: Is there any way to get tabs to align relative to the previous line?

texts:
Currently I have this javascript code in a js2-mode buffer after I press tab:

const entries = state.get('entries')
          .concat(getWinners(state.get('vote')));

and I would like for it to look like this aligned according to the dots

const entries = state.get('entries')
                     .concat(getWinners(state.get('vote')));

Is there any way to get emacs to behave like this? indent-relative does not seem to be the answer.


texts:
I realize that flycheck is a syntax checker that can be used with nearly every language's major mode.  My question is how (if at all) it can interact with modes such as (specifically) js2-mode which offer

  on-the-fly reporting of syntax errors and strict-mode warnings`.

This question answers how they are different but I am wondering if it
is better to just pick one mode or can they work together somehow?

I realize this could be opinion based so I am wondering If someone has an example of them working together how does it work?

Thanks


texts: Emacs plugin to browse Julia documentation, at point or textual

texts: It is quite annoying that I have to leave emacs to browse Julia documentation. Are there any nice plugins to get the documentation at point or that provides a nice direct textual interface to the Julia documentation?


texts: How do I enable the ODT item in the export dispatcher permanently?

texts:
I'm using Emacs 24.5.1, and my org-export-dispatch doesn't show "Export to ODT" by default. However, if I use M-x org-odt-export-to-odt, it works fine and the option is shown on the next dispatch.

How can I make the "Export to ODT" option permament without having to call org-odt-export-to-odt first?


texts: Navigation to source of compiled lisp function?

texts:
https://stackoverflow.com/questions/4222183/emacs-how-to-jump-to-function-definition-in-el-file and talk about navigation to source of functions.  They offer two options:

M-x find-function
C-h f  then use link in help buffer.

However, for a compiled function, neither work.

M-x find-function compilation-find-file

throws an error:

Debugger entered--Lisp error: (error "Can’t find library /usr/share/emacs/26.1+gg1+7/lisp/progmodes/compile.el")

If I used the help function path, I see:

compilation-find-file is a compiled Lisp function.

How can I fix these?


texts: How to disable a minor/major mode so that mwheel-scroll don’t take effect?

texts:
I am trying to have a simple solution to center the cursor at all times. I found that centered-cursor-mode was too slow and found this simpler solution.
The only problem is mouse scrolling no longer works unless I disable the minor/major mode I implemented to center the cursor.

I tried to advise mwheel-scroll to disable the mode but that was unsuccessful. I am not sure what I am doing wrong.

(define-minor-mode centered-point-mode
  "Always center the cursor on the screen."
  :lighter "..."
  (cond (centered-point-mode (add-hook 'post-command-hook 'line-change))
    (t (remove-hook 'post-command-hook 'line-change))))

(defun line-change ()
  (recenter))

(define-globalized-minor-mode my-global-centered-point-mode centered-point-mode
  (lambda () (centered-point-mode 1)))
(my-global-centered-point-mode 1)

(defun disable-centered
  (interactive)
  (centered-point-mode -1))

(advice-add 'mwheel-scroll :before (lambda () (interactive) (call-interactively 'disable-centered)))


texts: Compatibility with the function (ivy-switch-buffer) of ivy-mode and bm (a bookmark package)

texts:
The package ivy-mode has the function ivy-switch-buffer, which
use the build in variable bookmark-alist to incorporate bookmarks to its options.

I use the package bm to store my bookmarks, which use the file in the varaible bm-repository-file to save the bookmarks permanently.
I really like this package because it's simple to configure and use,
but the variable bookmark-alist has always nil value and ivy-switch-bufferdoesn't show my bookmarks.

The code (bookmark-load bm-repository-file) load the bookmarks from the field bm-repository-file to the variable bookmark-alist, but it says that the bm-repository-file is not in the "standard form"
(The function bookmark-loadis in the package bookmark+).

Could bookmark-alist be synchronized with bm-repository-file?
or, if they can not be synchronized, is there a function that transform the file bm-repository-file into such "standard form"?


texts:
I use Emacs to edit Go files. When I compile them I can use next-error to jump to the next error in a specific Go file. Very handy. However, when I also enable flycheck on my Go file for on-the-fly syntax checking, it somehow conflicts with the error reporting of the compilation. What I mean is when I compile a Go file that contains errors (not syntactic but semantic errors), the compilation window correctly shows the errors, but next-error doesn't work: it just displays the message:

No more Flycheck errors

If I disable Flycheck in the buffer, next-error works again correctly. It's as if Flycheck has hidden compilation errors. (I looked at next-error documentation and it does say it should cycle through all errors, but it doesn't do it in my case.) Emacs version:

GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7) of 2014-03-07 on lamiak, modified by Debian


texts: How to tell if -nw (no window) is in args?

texts:
I want a single .emacs but one that branches depending on whether -nw was in the argument list. (open in terminal [no window mode])

I.e, in gui mode I'd like all my usual features. In terminal I want it to load only the bare necessities for fast loading.

I looked at the command-line-args variable, but that var doesn't have flags.

Alternativley I've been considering not loading my regular init and load a custom terminal instead:
emacs -q -l "terminal_Config.el"
But if possible, I'd prefer to be able to tell if -nw was specified.


texts: Why is scrolling line-by-line so much slower compared to vi-mode?

texts: I was wondering if anyone has faced this issue before or is just me loosing my mind? It seems that C-n and C-p are so slow and sluggish compared to the j and k keys when using evil-mode. Is there any explanation for this or maybe some configuration that can make C-n and C-p behave similar to j and k in terms of speed.


texts: How can I enable lsp-headerline-breadcrumb-mode in lsp-mode?

texts:
I would like to enable lsp-headerline-breadcrumb-mode in every buffer where lsp-mode is active.
I'd know how to do it for every mode, for example
(use-package go-mode
  :ensure t
  :config
  (add-hook 'go-mode-hook (lambda ()
                            ;; other stuff
                            (lsp-headerline-breadcrumb-mode t)
                            )
            )
  )

But I fail to do it for every buffer with lsp-mode ...
With this, lsp-mode doesn't work at all:
(use-package lsp-mode
  :ensure t
  :commands (lsp lsp-deferred)
  :hook
  (go-mode . lsp-deferred)
  (python-mode . (lambda ()
                   (require 'lsp-python-ms)
                   (lsp-deferred)))
  :config (setq
           lsp-diagnostic-package :auto
           ;; stuff deleted
           lsp-print-performance nil
           )
  (add-hook 'lsp-mode-hook (lambda ()
                            ((lsp-headerline-breadcrumb-mode t))
                            )
            )
  )


texts: Emacs 24 with Elpy 1.7.50 does not recognize Python Project

texts:
Note: This was initially posted on StackOverflow a few months back and hasn't received an answer, but I'm reposting it since the Emacs StackExchange is now available.

I'm in the process of converting over from using Eclipse to Emacs 24.3 and Elpy 1.7.50 for my Python development.  However, I'm running into a roadblock in getting Elpy to recognize my project.  Based on my understanding of the way elpy should work from the documentation, if I set a project root folder, that folder should be included in the sys.path to search for modules.  This is not happening.

The Elpy Documentation doesn't seem to have any answers to my particular conundrum, nor can I find a basic tutorial that walks me through creating my first Elpy project to break it down and show me what I'm doing wrong.

In the shell, I first create the virtual environment virtualenv using
mkvirtualenv from virtualenvwrapper.  Then I create the following
folder/file structure within the virtualenv folder:

virtualenv/
└─ my_project/
   ├─ src/
   │  └─ my_project/
   │     ├─ __init__.py
   │     └─ foo.py
   └─ test/

The contents of foo.py are:

class foo(object):
    pass

if __name__ == '__main__':
    pass

Next, I connect to an already-running instance of Emacs server using the Emacs client. Within Emacs, I enter:

M-x pyvenv-workon virtualenv

Emacs does show [my_project] in the mode line.  Next, I enter:

M-x elpy-set-project-root ~/Projects/my_project/src

Then, I type C-cC-f to search the project for a file, and I get:

C-c C-f is undefined

So, I type:

M-x elpy-find-file

and I get:

No project root found

If I create the file test/test_foo.py with the following code:

from my_project import foo

if __name__ == '__main__':
    pass

and then run it using C-cC-c, I get:

>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/doug/Projects/my_project/src/test/test_foo.py", line 1, in <module>
    from my_project import foo
ImportError: No module named 'my_project'
>>>


texts: org mode: Numbered subtree whose parent has UNNUMBERED: t

texts:
As of version 8.3 of org, numbering of subtrees in export can be toggled via the :UNNUMBERED property.  This applies to subheadings regardless of their own :UNNUMBERED property value.  MWE:

* Heading
:PROPERTIES:
:UNNUMBERED: t
:END:
** Subheading
:PROPERTIES:
:UNNUMBERED: nil
:END:

This generates for LaTeX export

...
\section*{Heading}
\label{sec:orgheadline2}
\subsection*{Subheading}
\label{sec:orgheadline1}

Is there some other way to toggle this at the subheading level?  I need a heading to be un-numbered when exported to LaTeX, but its child subheading to be numbered.  I.e. \section*{Heading} and \subsection{Subheading}.


texts: Extended Cursor Movement in terminal emulator (CHA and others)

texts:
Is there a way to get the Emacs terminal emulator to support cursor movement escape sequences beyond its vt100 features? A specific example is CHA (Cursor-Character-Absolute), e.g. ESC[0G should move the cursor to column 0. CHA and a few other sequences were added as part of ISO-6429 (ECMA-48).

Try this rudimentary test in eterm and another terminal emulator:

printf "hello\033[0Gworld\n"

In eterm (M-x term or M-x multi-term) you will see:

helloworld

In Terminal.app I see:

world

For a full featured test check out vttest (brew install test for me).


texts: Easily update dates for a recurrent set of TODOs in org mode

texts:
Every semester I teach the same course and for every semester there are several TODOs that should, at least initially, have the same dates relative to the starting date (i.e. the first day of class).  How can I take the previous semester's course.org and easily update all of the TODO dates?

To exemplify with a MWE, imagine these were my TODOS this semester (I actually have plenty more)

** TODO prepare and distribute syllabus (first day of class: Sept 03, 2019)
   SCHEDULED: <2019-09-03 Tue>

** TODO explain group project (two weeks after classes started)
   SCHEDULED: <2019-09-17 Tue>

** TODO Create groups (on the Wednesday, three weeks after classes started)
   SCHEDULED: <2019-09-25 Wed>

How can I update these dates for this semester (where the first class falls, say, on January 13, 2020?)

(I am also happy to just create some sort of template (though preferably not a 'capture template') with variables for the initial dates and use a macro to fill them in).


texts: Access Table data from from elisp using headline ID

texts:
I have a bunch of recipes under different headline, and each have an ingredient list specified as a table.
I would like to access that table as an list in a src block using the headline id, same as if I where to use the name table name (which is very easy)
Truth to be told I have a usecase where I'd like to do the same for lists.
* Recepies
** Killer Sandwich
   :PROPERTIES:
   :ID: 0123
   :END:
   A really good sandwich!
   #+name: sandwich_recipie
   | 1   | piece | bread |
   | 100 | g     | cheese |
   | 100 | g     | butter |

#+begin_src elisp :var data=sandwich_recipie headline_id=0123 :results output
(= sandwich_data (magic-org-function-to-get-first-table-as-list headline_id))
#+end_src

So far I've been looking into org-element, but it seems like I'm not smart enough to use that... sorry


texts: Query-replace-regexp alternative capable of handling nested braces?

texts:
TL;DR

Is there some method in Emacs to replace text with nested braces/parentheses?

Example

I had a situation where I had to replace

\dchi{ARG1}{ARG2}

by

\chi^{ARG2}(ARG1)

For simple cases, this is easily be done with query-replace-regexp,

(query-replace-regexp
  "\\\\dchi{\\(?1:.*?\\)}{\\(?2:.*?\\)}"
  "\\\\chi^{\\2}(\\1)")

This will however choke on nested-braces structures.

Before replacement:   \dchi{\xx{0}{2}}{\yy}
Obtained replacement: \chi^{2}(\xx{1)}{\yy}
Wanted replacement:   \chi^{\yy}(\xx{0}{2})

Another example would be refactoring function calls with sub-calls, e.g.

Pattern             f1(ARG1, ARG2, ARG3, ARG4)
Replace by          f2(ARG4, ARG3, ARG2, ARG1)

Text with nesting   f1(A, B, f3(C, D), E)
Wanted replacement  f3(E, f3(C, D), B, A)
Likely result       f3(D, f3(C, B, A), E)

As I understand, this is simply a case, that goes beyond the capabilities of regular expressions (“they don't count”).

Such one-off use-cases typically are too easily fixed by hand to warrant writing a script that does the brace-matching, yet enough effort to be annoying.

Is there some other tool in emacs, that can help in such cases, or a shell-utility, that makes such generalized-regexp situations easier than writing a script froms scratch?


texts: Is there a way to globally unignore a file in projectile?

texts:
I have a few files that are ignored in most of the .gitignore project files, like .env and local-values.yaml.

Is there a way to not ignore them globally using projectile, so that I can find and open them with projectile-find-file?

Looks like a .projectile file would work, but sounds like it's per-project.


texts: Cancel printing of long string in buffer

texts:
Sometimes when in e.g. a Python or SQL buffer I accidentally evaluate something that outputs e.g. multiple megabytes of text into the buffer.

>>> zps = _read_zipfile_container(br.response().read(), br.geturl())
>>> len(zps)
1
>>> zps[0]  # oops
\xfc\xc0H\x19#\x15\x8a\xb4XN\xb5\x9b\xd2\xfeT\x9a\xbeL\xe7a\x90l\xb3Y\xfbL
\xf2Pq\x84\x941R\xa1H\xdb\x82\xe5T\x15\xb7]\xcd\xddk\xd2\xd9\x19$;\tHcW\x8
4\x83\xc1d\x06S\x10\xcc\xb60\xd9T\x89m=\xba\'\x1ay\x0b\x83d\x0bR\xfae\xd1F
H\x19#x15\x8a\xb4-XNUq\xdb]\xdeF\xdf\xde\xc2 \x99\x85A\x1a\x9b!\x1c\x9b!\x

... all one line, but rendered increasingly slowly to many
                            tens of thousands of continuation lines ...

At the moment I can either kill the process, or else wait for it to all render to the buffer and then delete it manually (might take a half hour, particularly when the output string has no linebreaks). I usually have to choose the latter option to avoid losing work in progress. Is there any way to discard the text without losing the buffer?


texts: Org Babel failing with Recursive Functions

texts:
I’ve done quite a lot of source level blocks in org-mode, but I think I have a failure scenario if called functions inside the source code blocks are recursive.

The ifconfig program displays all the important information, just in the wrong format. Let’s fix that. First, let’s retrieve the results and we’ll store that in a name, ifconfig_data:

#+NAME: ifconfig_data
#+BEGIN_SRC sh :results drawer
  ifconfig -a
#+END_SRC

Which spills out:

#+RESULTS: ifconfig_data
:RESULTS:
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        options=3<RXCSUM,TXCSUM>
        inet6 ::1 prefixlen 128
        inet 127.0.0.1 netmask 0xff000000
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
        nd6 options=1<PERFORMNUD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ether 6c:40:08:b7:ce:b8
        inet6 fe80::6e40:8ff:feb7:ceb8%en0 prefixlen 64 scopeid 0x4
        inet 192.168.77.40 netmask 0xfffffe00 broadcast 192.168.77.255
        nd6 options=1<PERFORMNUD>
        media: autoselect
        status: active
...

We can access that data easily in standard org-mode Babel thingie:

#+BEGIN_SRC elisp :var datastring=ifconfig_data :results value
  (format "Results: %s" datastring)
#+END_SRC

However, the output format is awful, and I would like to have a list of tuples, where each tuple has the interface and the IP address.  Since some interfaces may not have an IPv4 address (which is what I’m wanting).

To address this, I have a recursive function that calls itself for each regular expression match:

1. Matched the Interface
   2. The name of the Interface
3. Matches the Address
   4. Optional `addr:` section that we don’t care about
   5. The value of the address

If the match is on an address, we assume that we passed in the interface name as a header parameter, so that we can /build up/ the result.

#+NAME: ifconfig-display
#+BEGIN_SRC elisp :var datastring=ifconfig_data :results value
  (defun split-ifconfig (datastr pos header)
    "Assumes that the DATASTR is a string datastrput from ifconfig.  The POS is position within the string to search.  The HEADER is the current interface address."
    (when (string-match "\\(^\\([^ :]+\\):?\\ \\)\\|\\( *inet \\(addr:\\)?\\([0-9.]+\\)\\)" datastr pos)
      (cond
       ;; Interface:: Recurse with the name of this new header
       ((match-string 1 datastr)
            (split-ifconfig datastr (match-end 0) (match-string 2 datastr)))

       ;; Address:: Return a list with our interface header, the
       ;;           address, and the results of parsing the rest
       ((match-string 3 datastr)
            (cons (list header (match-string 5 datastr))
                    (split-ifconfig datastr (match-end 0) nil))))))

  (split-ifconfig datastring 0 nil)
#+END_SRC

This works if I evaluate the function stuff directly with C-x C-e.

The last line, however, in the code block returns nil. Always. The datastring contains the data. The function, split-ifconfig that was defined in the function is called. Still no go.

This doesn’t work, even if I pre-load the function into the global function space, and call it from the block:

#+BEGIN_SRC elisp :var out=ifconfig_data :results value
  (split-ifconfig out 0 nil)
#+END_SRC

I’ve tried making the datastr aspect a global variable, and not keep passing it. Still no go.


texts: How can I pass an expression to a prefix argument?

texts:
Sometimes it would be useful to be able to pass an expression to a prefix argument, for example
c-u 3*4 c-n

If I try the command above though it will print three asterisks followed by the '4' character then cursor-down.
Is there something I can do so the prefix argument can be the value of an expression?


texts: how to make org-mode section numbers start counting from 0 instead of 1?

texts: org-mode section numbers (when exported to html) by default starts count from 1, however it is traditional in computer science to start counting from zero. How to make org-mode section numbers start counting from 0 instead of 1?


texts: Moving forward / backward using a hexadecimal offset

texts:
There is hexl-forward-char which lets me move forward/backward specifying a decimal offset.

And there is also hexl-goto-hex-address to specify an absolute location using a hexadecimal number.

Is there perhaps also something builtin that lets me move by an hexadecimal offset, or do I need to roll my own here?


texts:
Is it possible to set a title for a block in multi-command agenda view? I currently see this:

... normal agenda view here
========================================================================================
Headlines with TAGS match: -SCHEDULED={.+}-DEADLINE={.+}/-DONE-DEFERRED-CANCELLED
  work:       TODO Some task

I'd like to replace the line starting with "Headers with TAGS" with a custom title, eg "Unscheduled tasks".

This is the value of org-agenda-custom-commands:

  (setq org-agenda-custom-commands
        `(("n" "Agenda and TODOs"
           ((agenda "")
            (tags "-SCHEDULED={.+}-DEADLINE={.+}/-DONE-DEFERRED-CANCELLED")
            (alltodo "")))))


texts: org-fill-paragraph in a list with checkboxes doesn't take into account the checkboxes

texts:
I'm trying to figure out a way to change the behavior of org-fill-paragraph for a list with checkboxes. I would like the indentation to take into account the checkbox, but here is what I see:

- This is a long line in a plain list and fill-paragraph works as I expect
  it would (it takes into account the marker for the list in the indentation)

- [ ] But when I write a long line with a checkboxed list, the behavior
  of fill-paragraph is to ignore the checkbox and indent as if the checkbox
  is not there

- [ ] This is the way I would like to see a long line in a checkboxed
      list. Currently, the only way I can achieve it is by manually adding
      spaces in the beginning of the line

I realize that some people may prefer the current behavior, but is there a way for me to achieve my desired behavior?

Thanks


texts:
I'm using org-mode and visual-line-mode with Spacemacs by pressing <SPC> t l.  However, when I do this I get strange behavior, possibly due to the visual indenting of lines.  As I move between lines, the cursor seems to jump all over the place.  I've recorded a short video of it that you can see below. You can see as I move down (j) the lines, especially from the first row of a paragraph to the second, the cursor jumps. Also, as I move up (k), occasionally the cursor will skip a line.  How do I make these two modes play nice with each other?

https://gfycat.com/SpicyGiganticAmazontreeboa


texts: What Magit command allows re-editing the todo list, during a rebase?

texts:
Magit's magit-interactive-rebase function handles the Git interactive rebase very well.

But there's one action it seems to be missing. According to git-rebase(1), the four actions during interactive rebase are --continue, --skip, --abort, --edit-todo.

That last one doesn't appear to be available in Magit. How can I tell Magit to:

Present the rebase todo document again, for editing. Then
Continue on, obeying the edited rebase todo document.


texts: How to programmatically extract path to etags executable

texts:
Q:  Assuming that we open Emacs with a path to ../Emacs.app/Contents/MacOS/Emacs, how can we programmatically extract the path to etags located at ../Emacs.app/Contents/MacOS/bin/etags.  [The location of Emacs.app will vary.]

I want to build my own TAGS index for certain files from the Emacs source code that I am tinkering with in a project directory containing only those files.  Here is link to the draft function that I am using to build tags:  find-tag: Build a new TAGS file if it does not already exist

OSX comes with an outdated version of etags located at /usr/bin/etags.  I have recently learned that the outdated version of etags fails to index a ton of stuff in the current source code used to build Emacs.  That discovery, combined by a lesson from Eli Z. over on reddit (i.e., calling make tags), led me to the command line ../emacs/lib-src/etags.  The etags executable that is used in Emacs 26 and the current version of the master branch is superior in terms of its ability to properly index the source code.  When calling make install (assuming Emacs was configured --with-ns), a packaged Emacs is created with a folder/package called Emacs.app.  I am making a leap by assuming that the executable located at ../Emacs.app/Contents/MacOS/bin/etags is the same as found in the source code tree ../emacs/lib-src/etags.  [If that assumption is wrong, please let me know.]

While the normal location of packaged applications ending in .app (on OSX) is in /Applications, I place them in other locations.  And, I have several versions of Emacs strewn about on my hard drive that I use periodically for different reasons.


texts: GUI started emacs has different env vars than terminal started one

texts:
I wrote LD_LIBRARY_PATH both in .bashrc and .bash_profile.
However, if I started emacs in terminal using emacs, LD_LIBRARY_PATH is shown in getenv.
If I started it using GUI, there is no such variable.
I am on ubuntu 20.04. How could I make GUI started emacs have same env vars as terminal started one?


texts:
I run M-x gdb  using emacs integrated with the shell (-nw) but when I debug programs it doesn't display the output step by step.

I mean that it returns the output only at the end when the program finishes and there is no output displayed immediately after the output commands.

How can I fix this problem?


texts:
It's easy to make whole words bold, italic etc. by using the asterisk/slash before and after the word. It's imperative however to also have a space in front of the opener markup, and after the closer markup. In other words, this easy (to use and easy to read) way of marking text is limited to start and end with space boundaries.

When using org-mode with languages that don't use spaces (Japanese, Chinese, etc.), adding a space just to make a word bold in those languages will make the formatting look quite ugly.

For html-export I could do the following, but that's neither handy, nor easy on the eye when looking at the org source.

abc@@html:<b>@@def@@html:</b>ghi

Does org-mode provide a better option?


texts: Make Jabber.el stop alerting me when new messages are written on MUC, unless I'm highlighted

texts:
I tried to follow emacswiki article about Jabber.el to configure it on my Emacs. However, my changes do not works.

Alerts stealth the minibuffer, and its annoying to see an alert when I'm doing something there.
I get alerts for every message people send to MUCs, which is something I would really like to avoid and instead being alerted when somebody highlights me.
I cannot set xmessage for alerts (I tried linnotify, but it doesn't works; maybe is something with my tiled window manager SpectrWM), and when some activity happens the MUC's name is added to the modeline, clobbering it.

Jabber.el is a great package, but this things make it annoying and distracting, how can I fix them?

My Emacs conf for Jabber.el:

(setf
 jabber-history-enabled t
 jabber-use-global-history nil
 jabber-backlog-number 40
 jabber-backlog-days 30
 jabber-alert-presence-message-function (lambda (who oldstatus newstatus statusnext) nil)
 jabber-invalid-certificate-servers '("chat.deshackra.com")
)

(defun notify-jabber-notify (from buf text proposed-alert)
  "Notifica sobre nuevos mensajes en Jabber vía notify.el"
  (when (or jabber-message-alert-same-buffer
           (not (memq (selected-window) (get-buffer-window-list buf))))
    (if (jabber-muc-sender-p from)
        (notify (format "(MP) %s"
                        (jabber-jid-displayname (jabber-jid-user from)))
                (format "%s: %s" (jabber-jid-resource from) text)))
    (notify (format "%s" (jabber-jid-displayname from))
            text)))

(defun my-jabber-chat-delete-or-bury ()
  (interactive)
  (if (eq 'jabber-chat-mode major-mode)
      (condition-case e
          (delete-frame)
        (error
         (if (string= "Attempt to delete the sole visible or iconified frame"
                      (cadr e))
             (bury-buffer))))))

;;(define-key jabber-chat-mode-map [escape] 'my-jabber-chat-delete-or-bury)
;;(add-hook 'jabber-alert-message-hooks 'notify-jabber-notify)

(if (daemonp)
    ;; nos conecta a todas las cuentas jabber!
    (progn
      (load-file (expand-file-name "jabber.secret.gpg" user-emacs-directory))
      (ignore-errors
        (jabber-connect-all))))


texts:
I try to add a nicer key binding to kill the current buffer.

An obvious solution is to use kill-this-buffer, but often it does not work, or e.g. does not work the first time. The key binding for it is definitely not overridden by the buffers keymap, etc.

Indeed, the docs for kill-this-buffer say:

  This command can be reliably invoked only from the menu bar, otherwise it could decide to silently do nothing.

This is exactly the observed behavior.

What could be a nice alternative? Is something like (kill-buffer (current-buffer)) going to work reliably instead? Am I missing any subtleties?


texts: Asynchronous export to PDF from org-mode

texts: Is it possible to configure org-mode to export to PDF in and asynchronous way?


texts: I always want the tab width to be 4 spaces, no matter what.  How do I do it?


texts: Identify remote directories and open files through tramp from emacs terminal

texts:
Emacs terminal (from multi-term) can automatically detect a folder path. So  performing C-x C-f from a local directory, automatically provides the path to that directory to open any relevant files.

My questions is how to do the same for a remote directory that was accessed through ssh from emacs terminal? Since, if I perform C-x C-f, it only tries to open the local directory from which ssh connection was launched. How to automatically pass information to tramp to help open the files in the remote directory?

I'm looking for something similar to this question, but for term or multi-term, since shell does not seem to recognize the local alias and other shortcuts that are stored in ~/.bashrc of the remote server.


texts: How to disable org-metaleft in org capture?

texts:
The combination of org capture, org-metaleft (bound to S-LEFT), and refiling can mess up an org file. Here is an example:

Start a new heading with quick capture, say *** new. This heading is refiled depending on your quick capture template, say ** Miscellaneous.
Press S-LEFT twice, which is bound to org-metaleft and which I often use to go back a word instead of M-b. The heading *** new becomes * new and all the next level 2 headings will become children of this new heading.
Refile with C-c C-w, say to * Today. The heading becomes ** new and carries all the children with it to the new location.

The problem with this behavior is that it is completely hidden, unlike in the main buffer where I would see it happening. So I think org-metaleft should be disabled in org capture.

Why is it enabled, and how to turn it off?


texts: find-file-hook but only if file is selected

texts:
This is pretty simple, I'm trying to find (or build) a hook that fires when files are visited and selected (i.e. immediately displayed).

Background

I'm writing a UI centric entry for find-file-hook, but it turns out that find-file-hook is fired for all sorts of things that I don't need:

Semantic assets which are loaded when semantic starts
Files opened in the background for my on-the-fly diffing program
Probably other stuff, that's all I could think of off the top of my head

Most of this is done by way of find-file-noselect, which associates a buffer with a file, but does not switch-to-buffer on the newly created buffer like find-file does.

I would like my hook to execute only when the current buffer changes.


texts: Flycheck with file relative eslint executable

texts:
A lot of projects I work on install eslint as a dev dependency, with a custom set of eslint plugins. Right now, flycheck uses the globally installed version of eslint rather than the version of eslint installed with each project.

I would like to make flycheck point to node_modules/eslint/bin/eslint.js instead. The full path should depend on the path of the current buffer's file so I can be working on multiple projects at the same time with each buffer using a potentially different eslint executable.

Is this possible? Any suggestions for how I would go about doing this?


texts: Updating taskpaper major mode to add date to @done tasks

texts:
I am trying to update the fairly old taskpaper major mode for Emacs found here to simply include the current date, whenever I mark a task as done. The line should then read:

- Task @done(2015-07-13) instead of just - Task @done.


texts: Can I import a rectangle from one org-table into another org-table?

texts:
I have an org document with two different-sized tables table1 and table2.

#+TBLNAME: table1
|   |   |   |   |   |   |   |
|---+---+---+---+---+---+---|
|   |   | x | x | x | x | x |
|   |   | x | x | x | x | x |
|   |   | x | x | x | x | x |
|   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |
#+TBLFM: @2$3..@4$7=x

#+TBLNAME: table2
|   |   |   |   |   |   |   |   |   |   |
|---+---+---+---+---+---+---+---+---+---|
|   |   |   |   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |   |   |   |
|   |   |   |   | y | y | y | y | y |   |
|   |   |   |   | y | y | y | y | y |   |
|   |   |   |   | y | y | y | y | y |   |
|   |   |   |   |   |   |   |   |   |   |
|   |   |   |   |   |   |   |   |   |   |
#+TBLFM: @6$5..@8$9=y

The region in table1 marked with x's and the region in table2 marked with y's are both arrays with three rows and four columns. I want to import the information in the indicated region of table2 into the indicated region of table1.

Reading through the org documentation it appears that something like

#+TBLFM: @2$3..@4$7='(identity remote(table2, <STUFF>))

might work, but I can't figure out what <STUFF> should be. Any ideas?


texts: Magit refs buffer no longer able to switch branches

texts:
After last update, the *magit-refs buffer no longer switches to the branch under point when pressing RET, instead, it shows last commit from the branch I wanted to check out (completely useless behavior, at least for me). Is there any way to have RET work as it used to?

I figured I could do bbRET, to achieve the same effect, but I'm too used to RET working as it used to, and when accidentally I press it, Emacs hangs because the diff may be quite large.


texts:
Using smartparen, if I have some text I can select it then press
( { or [ and the text is wrapped in those braces. How can I extend this functionality so that (in Latex for example) if I press $ the text is wrapped in $...$ or if I press " the text is wrapped in LaTeX quotes. Can it also be done with two letter pairs like \( ?

I feel that this is straightforward, but I haven't been able to get it working with sp-local-pair and couldn't find a similar question.


texts:
I want to customize how a link is prettified.  Specifically, I want Org-Ref's cite links to display the bibiliography key.

A cite link looks like:

[[cite:my-bib-key][pg. 2]]

The default prettified display looks like:

pg. 2

How can I tweak org-mode to get this display instead:

@my-bib-key: pg. 2


texts: Separate customizations according to modes

texts:
Using emacs 25.2.2 on Kubuntu 18.04.

I have customized several variables using M-x customize-variable. So, there is a large custom-set-variables section at the very beginning of my init.el. Moreover, there are several key-bindings, etc. in the same file.

Now, I want to separate my customizations across different files. So, all org-related customizations (variables and key-bindings) will go in org-settings.el, etc.

So, I created org-settings.el with the

(custom-set-variables
 '(org-agenda-follow-indirect t)
 '(org-agenda-show-inherited-tags nil)
 '(org-agenda-skip-scheduled-if-done t)
 '(org-agenda-span (quote day))
)
;; Useful key bindings
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-cl" 'org-store-link)

In my init.el I then added (load "org-settings.el").

Funny thing is, every time I restart emacs, all org custom variables from org-settings.el are copied back to init.el.

How do I solve this? I would love to have a clean init.el.


texts: Match two spaces with incremental search

texts:
When searching using:

C-s SPC SPC

Also matches single spaces. I want to match exactly two space.


texts: How to apply `load-theme-buffer-local` with "default" theme?

texts:
I used this answer to try to get eww to use more readable colours for me in my configuration, which uses the monokai theme:

https://emacs.stackexchange.com/a/3523/5495

That answer uses load-theme-buffer-local.  Using the answer as-is (with the tango theme) still gives different results than running eww from emacs -q (in particular, a darker background if I visit https://news.ycombinator.com/).

Is there a different theme name I can use here that will give results similar to what I get before applying any theme?  Or some other way to get an equivalent effect -- i.e. effectively not applying the monokai theme to eww buffers?


texts: I restart my emacs a lot. All I want to do is create a function that kills the current emacs, only to spawn a new one in it's stead. Ideally, this would also work in a TTY.


texts:
I have auto-complete and jedi installed and everything works just fine except autocompletion in PyQt5. When i try to subclass for example QWidget and in the __init__ method I type self and then press dot on my keyboard which triggers autocompletion popup it gives me an error:

deffered error : (error "RuntimeError('generator raised StopIteration')")

When I issue command jedi:pop-to-epc-buffer I see a number 56977 and repeated error message.

Here's my emacs config reffered to jedi:

(use-package jedi
  :ensure t
  :init
  (add-hook 'python-mode-hook 'jedi:setup))

(setq jedi:complete-on-dot t)

Any ideas what causes this error?

EDIT:

This is sample code (# is the position of cursor):

from PyQt5.QtWidgets import QWidget

class MyWidget(QWidget):
    def __init__(self, parent = None):
        super().__init__(parent)
        self.#


texts: How to get the number of rows between hlines for orgmode table formula?

texts: In my orgmode table formula, i would like to get the number of rows between hlines (for example: @I..@II). Does anyone know how to do it?


texts: why does emacs sometimes prepend asterisks to org mode headings

texts:
When I open this file in emacs

https://raw.githubusercontent.com/limist/literate-programming-examples/master/01-clojure-literate-ants/literate-ants.org

I see emacs is showing me ** lines as *** lines.

Whats the logic behind this?

Update:
    I noticed the file has a heading like this
    #+STARTUP: align indent fold nodlcheck hidestars oddeven lognotestate


texts: How best to export functions in dynamic modules

texts:
Background

I am running Emacs version

GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2017-05-28

I am writing a toy dynamic module to interface with GNU/Linux utilities following this guide. My module compiles, loads and runs successfully, but the information reported by the help system leaves something to be desired. Is there a way to achieve the same level of integration as with built-in functions?

Module definition

My module foo.c (which compiles to foo.so) includes the following:

#define FOO_DOC "Frobnicate BAR.\n\n(fn BAR)"

static emacs_value Ffoo (/* ... args ... */) { /* ... body ... */ }

int
emacs_module_init (struct emacs_runtime *ert)
{
  emacs_value Qfset, Qprovide, Qfoo, Sfoo;
  emacs_env *env = ert->get_environment (ert);

  Qfset    = env->intern (env, "fset");
  Qprovide = env->intern (env, "provide");
  Qfoo     = env->intern (env, "foo");
  Sfoo     = env->make_function (env, 1, 1, Ffoo, FOO_DOC, NULL);

  env->funcall (env, Qfset,    2, (emacs_value[]) {Qfoo, Sfoo});
  env->funcall (env, Qprovide, 1, &Qfoo);

  return EXIT_SUCCESS;
}

Desired behaviour

Here is an example of what describe-function reports for mapc:

mapc is a built-in function in ‘src/fns.c’.

(mapc FUNCTION SEQUENCE)

Apply FUNCTION to each element of SEQUENCE for side effects only.
Unlike ‘mapcar’, don’t accumulate the results.  Return SEQUENCE.
SEQUENCE may be a list, a vector, a bool-vector, or a string.

where the quoted filename src/fns.c forms a link to the function's definition.

Actual behaviour

When the module function foo is defined using fset, as per the source listing above and the linked blog post, describe-function reports the following:

foo is .

(foo BAR)

Frobnicate BAR.

Furthermore, inspecting load-history reveals the following:

("/path/to/baz.el"
 (require . foo)
 (provide . foo)
 ;; ... other baz.el definitions ...
 (provide . baz))

where baz.el calls (require 'foo) and which itself gets loaded as part of my startup.

If I replace fset with defalias in the module, I instead get:

foo is in ‘baz.el’.

(foo BAR)

Frobnicate BAR.

and load-history includes an additional defun:

("/path/to/baz.el"
 (require . foo)
 (defun   . foo)
 (provide . foo)
 ;; ... other baz.el definitions ...
 (provide . baz))

Questions

How can I tell Emacs that the function foo is a function and defined in the dynamic module foo.c, not the elisp file which loaded it, baz.el?
Does the help system support links to module sources?
Is there a better way to export module functions than the described defalias approach?
Is there a better way to load a module than (require 'module-feature)?


texts:
I'm an emacs newbie and am using evil mode for text formatting. I have some text in the following format:
word1 = meaning with elaboration; word2 = simpler meaning; word3; word4 = much long explanation needed;

and want to wrap each of word1, word2, word3 etc.. into \textif\textbf{word1}}, \textif\textbf{word2}} etc. and transform the original text as
\textif{\textbf{word1}} = meaning with elaboration;
\textif{\textbf{word2}} = simpler meaning;
\textif{\textbf{word3}};
\textif{\textbf{word4}} = much long explanation needed;

In VIM, I verified separately that the following search+replace pattern applies the changes for word2, word3 and word4 (I know this pattern won't change word1)
:%s,;\s*\(\w*\),; \r\\textit\{\\textbf\{\1\}\},g
However, this doesn't work in emacs. All I see is Ex: Syntax error
Does vim-style search+replace work in emacs? Is there a way to apply the same search+replace in emacs?


texts: how to get seconds on org-clock measurements?

texts:
With C-c C-x C-i and C-c C-x C-o we can get measurements on how much time we spend on tasks:

:LOGBOOK:
CLOCK: [2016-11-21 Mon 22:50]--[2016-11-21 Mon 22:57] =>  0:07
CLOCK: [2016-11-21 Mon 22:30]--[2016-11-21 Mon 22:30] =>  0:00
:END:

But the smallest unit is a minute. How can we get measurements in seconds?


texts: C-S-n and C-= not working in emacs if running within terminal

texts:
I am running emacs inside tmux within iterm2 on OSX. For some reason these key bindings do not work properly

C-S-n
C-=
C-+
C-;

And some others too that are similar.
All of these work when running within X.
Any ideas why?

I'd hate to revert C-= to C-c = in terminal mode.


texts: How to speed up the initial use of `helm-M-x`?

texts: When I run helm-M-x (SPC :) in Spacemacs, the first time is slow in loading/showing. Is there a way to "preload" it during startup/.spacemacs?


texts: Thumb could not be created for file xxx.png

texts:
Windows 10, Emacs 25.1, Dired+

I want to open image file from Emacs.
I start Emacs by emacs -Q

So in tutorial:

To enter Image-Dired, mark the image files you want to look at in the Dired buffer, using m as usual. Then type C-t d (image-dired-display-thumbs).

I do this steps but I get error:

Thumb could not be created for file d:/TEMP/test/nokia_path.png

Here screenshot:


texts: I have Tabbar installed and when I am using some function like describe-key in emacs the resulting *help* buffer has a tab bar at the top. This is a waste of space and is distracting. How can I disable the tab bar in popup buffers or just special buffers in general?


texts: Drunken font lock in a long-running session

texts:
I'm running the emacsformacosx.com build of Emacs 25.2.1 in daemon mode. I connect to it through emacsclient invoked from various tmux sessions in macOS Terminal. $TERM is xterm-256color. The daemon process is long-running, ideally lasting for days or weeks until a reboot is required.

At first everything is fine, but font locking eventually craps out. Here's an example from an orgmode buffer:

There is a link around the "This is a link" line. Everything after should be regular text.

It's not orgmode-specific. Other modes exhibit similarly weird effects, as if font lock is getting slightly drunk.

It's not syntax-specific. If I toggle font-lock-mode, everything renders correctly but the problem is still present and resurfaces at the next point of syntax highlighting.

I don't think it's my configuration. I'm not doing anything exotic (with font locking, or in general), and my packages are up-to-date.

I can avoid the issue by restarting the daemon, but is there a better solution?


texts: Recover a built-in function that I accidentally unbound

texts:
I accidentally unbound a built-in function (a subr) from its usual symbol. Is there a generic way to recover it?

Of course I could save my buffers and my session, exit Emacs and start another instance. That is, if the function I lost wasn't needed to save and exit. What can I do if I lose some really fundamental function such as write-region or get-buffer?


texts:
I am using mu4e for email in Emacs, and it is currently only
configured for one mail account, and I set key to view different inbox. I wonder how to use mu4e for managing multiple email accounts?


texts: How can i add same value to every item in list, turning it into alist?

texts:
I tried to use this code, but it returns (k k k k k)

(mapcar (lambda (x) 'cons x '(k))
        '(a b c d e))

What am i doing wrong here? Why doesn't cons work?


texts: inserting ascii pipe into an org-mode table

texts:
I need to be able to have a table entry that looks like this

| ~Comonad~   | ~copoint~ | ~F[A]~ | | ~A~ |
| ~Semigroup~ | ~|+|~     |        | |     |

but org-mode insists on treating the pipes in |+| as columns.

I am aware that I can use vert as per https://stackoverflow.com/questions/11876048 and http://orgmode.org/manual/Special-symbols.html#Special-symbols but this doesn't work when it's in a code block.

What to do? I'm not keen on the UTF-8 pipe hack.


texts: Mac OS Keychain with SMTP email password

texts:
How do I get Emacs to use the Mac OS Keychain for my SMTP email password?

I'd like to eschew an .authinfo file in favour of the Mac OS Keychain
but can't seem to get it going. I keep receiving the error auth-source-macos-keychain-search: The MacOS Keychain auth-source backend doesn't support creation yet.

Some relevant excerpts from my init file:

'(auth-sources (quote (macos-keychain-internet macos-keychain-generic)))
'(smtpmail-smtp-server "mail.example.com")
'(smtpmail-smtp-service 465)
'(smtpmail-smtp-user "user@example.com")
'(smtpmail-stream-type (quote ssl))
'(send-mail-function (quote smtpmail-send-it))

I have created an entry with Keychain Access in my default keychain with
the following:

Keychain Item Name: mail.example.com
Account Name: address@hidden
Password: password12345

The following commands return the password:

$ security find-generic-password -l mail.example.com -a address@hidden -w
=> password12345
$ security find-generic-password -s mail.example.com -a address@hidden -w
=> password12345

However, if I eval

(auth-source-search :label "mail.example.com")
=> nil
(auth-source-search :server "mail.example.com")
= nil
(auth-source-search :label "mail.example.com" :user "address@hidden")
=> nil

The Mac OS authorisation popup appears, but I can't tell whether it's
returning the password...

I have the security retrieval method working for OfflineIMAP using the
real Keychain entry, so it's not a user/password problem.

I'm happy to switch to another send-mail-function.


texts: How to extract symbols from an elisp buffer?

texts:
While I could parse the elisp myself, is there a way to extract symbols from an elisp buffer?

That is, variable names, macros & functions - not part of strings.


texts: How to troubleshoot and diagnose escaped-character display errors in Emacs shell?

texts:
I make much use of sub-shells within Emacs (initiated via M-x shell), and, because of this, I run into problems like the one illustrated1 below way too often:

$ python -m pdb /tmp/hello_world.py
[2] > /tmp/hello_world.py(1)<module>()
-> print 'Hello, world!'
^[[1A
(Pdb++) l
^[[1@l^[[9D
  1  -> print 'Hello, world!'
[EOF]
^[[1A
(Pdb++) quit()
^[[1@q^[[1@u^[[1@i^[[1@t^[[1@(^[[1@)^[[14D
$

In a regular terminal, the same interaction looks like this:

$ python -m pdb /tmp/hello_world.py
> /tmp/hello_world.py(1)<module>()
-> print 'Hello, world!'
(Pdb) l
  1  -> print 'Hello, world!'
[EOF]
(Pdb) quit()
$

Whenever this sort of thing happens I resort to Google, and start trying the random fixes I find, more or less blindly, until one works, if any.

In this example, I've run python within an interactive debugger, all under a sub-shell, under Emacs (yes, it's quite a tower I've got here).

Here, Python's side of the interaction includes several escaped characters (preceded by ^[) that are not properly displayed.

Whenever this happens I resort to Google, and start trying the random fixes I find, more or less blindly, until one works, if any.

Is there a more systematic way to troubleshoot, diagnose, and (hopefully) fix such problems?

1In the display above, I've simulated things by rendering some characters the way they appear on my screen.  Namely, I used two normal characters ^ and [ to display what is actually a single character, namely ASCII 27, aka ESC.


texts: How do I get Flymake to work for SCSS mode?

texts: I have flymake-sass working, but I can't get it to work for SCSS files. The source looks like it should work with SCSS, but when I try to enable it I get an error about scss-sass-options not being defined. After defining that as nil in .emacs it loads but doesn't do anything.


texts:
RefTeX doesn't support Org #+LABEL: syntax by default, but can it be customized to do so? For example, if I have #+LABEL: foo, I'd like to be able to insert a reference to that label using RefTeX.

I've been browsing the customize options, and it appears like it may be possible to set some preferences and gain better Org support. I've played around with the following:

(setq reftex-try-all-extensions)
(setq reftex-file-extensions
       '(("org" "nw" "tex" ".tex" ".ltx") ("bib" ".bib")))
(setq TeX-file-extensions
       '( "org" "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))

And then found

(setq reftex-label-regexps
           '("\\\\label{\\(?1:[^}]*\\)}"
             "\\[[^]]*\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?"))

To which I tried adding the regexp:

"\\\#\\\+LABEL:\\(?1:*\\)"

But have had no success. It seems like reftex-label-alist may also be needed.


texts:
First example:

(defun first (a)
    '(a 1))
(first 2) => (a 1)

Second example:

(defun second (b)
    (+ b 1))
(second 1) => 2

How can I get (2 1) with (first 2)?


texts: Moving list item that contains a code block in org mode

texts:
In the following minimal example:

* Heading
- Item Foo
#+BEGIN_SRC sh
echo "Hello World!"
#+END_SRC
- Item Bar

It is impossible to move the bar item above foo using org-move-item-up. Is there a way around this?


texts:
I am running Emacs 26.1 on MacOs Mojave and have problem to play sounds with
pomidor:

pomidor is installed in ~/.emacs.d/elpa/pomidor-20180614.828

Reference to the source code pomidor.el, it warn that
(warn "This Emacs binary lacks sound support")))

 120 (defun pomidor-play-sound-file-emacs (file)
 121   "Play FILE by starting new Emacs process."
 122   (if (fboundp 'play-sound-internal)
 123       (start-process "pomidor-play-sound-file-emacs"
 124                      nil
 125                      (car command-line-args)
 126                      "-Q"
 127                      "--batch"
 128                      "--eval" (format "(play-sound-file \"%s\")" file))
 129     (warn "This Emacs binary lacks sound support")))

Since it fails to play sounds, I config the ~/.emacs.d/init.el following the instruction TatriX/pomidor: Pomidor is a simple and cool pomodoro technique timer.

1, To disable or configure sounds:

(setq pomidor-sound-tick nil
      pomidor-sound-tack nil
      pomidor-sound-overwork (expand-file-name (concat pomidor-dir "overwork.wav"))
      pomidor-sound-break-over (expand-file-name (concat (getenv "HOME") "/Music/overwork.wav")))

and place the sounds to Musics directory

$ ls ~/Music
iTunes  overwork.wav  tack.wav  tick.wav

When restart emacs it prompts:

Symbol's value as variable is void: pomidor-dir
pomidor.el reside in:
$ pwd ; tree
/Users/gaowei/.emacs.d/elpa/pomidor-20180614.828
.
├── overwork.wav
├── pomidor-autoloads.el
├── pomidor-pkg.el
├── pomidor.el
├── pomidor.elc
├── tack.wav
└── tick.wav

2, Provide customized function to play sounds

  if your Emacs can't play sounds you can provide your own function to do it:

(setq pomidor-play-sound-file
      (lambda (file)
        (start-process "my-pomidor-play-sound"
                       nil
                       "mplayer"
                       file)))

I wait 2 hours to run 3 pomodoros, but it stayed mute.

I checked the problem and find there is not such a function called "my-pomidor-play-sound" in pomidor.el.

$ grep -n 'my-pomidor' pomidor.el
#return nothing
$ grep -n 'pomidor-play' pomidor.el
120:(defun pomidor-play-sound-file-emacs (file)
123:      (start-process "pomidor-play-sound-file-emacs"
131:(defcustom pomidor-play-sound-file #'pomidor-play-sound-file-emacs ;;
329:  "Play FILE using `pomidor-play-sound-file' function if any."
330:  (when (and file (functionp pomidor-play-sound-file))
331:    (funcall pomidor-play-sound-file file)))

It comes to conclusion that I should write a defun my-pomidor-play-sound then could start-process

Alternatively, I found a solution org mode - Play Org-Pomodoro sounds - Emacs Stack Exchange

Which simple introduce M-x package install sound-wav.

Unfortunately, the pomidor keeps mute.

How could I get it playing sounds?


texts: How to check a regular expression is valid without using it for a search?

texts:
I would like to write a package that uses user defined regular expressions.
Is there a way to validate a regular expression is valid without having to perform a search, showing a helpful message when it's not?


texts: Red and Rebol have multiline strings that start with { and end with }. Reading through Elisp docs I don't see any simple way to define this in the syntax table. The string quotes class matches the same character only and the generic string delimiters class wouldn't work correctly either.


texts: time-zone-valid-p: Is there such a function?

texts:
I am trying to debug an invalid timezone '(nil nil nil) that is causing encode-time to choke on the optional ZONE argument.

Q:   Is there a time-zone-valid-p function anywhere that I can use to test the ZONE before passing it to encode-time?


texts: Only enable whitespace mode in certain buffers

texts:
I would like to have whitespace mode turned on for all buffer except for org-mode ones.  It is easy to do this when emacs starts up, but since I use a persistant copy of emacs with emacs daemon mode I can't just do it that way.

I tried:

(require 'whitespace)
(setq whitespace-line-column 80)
(setq whitespace-style '(face lines-tail))
(global-whitespace-mode t)
(add-hook 'org-mode-hook
      (lambda ()
          (visual-line-mode 1)
          (auto-fill-mode -1)
          (setq whitespace-style nil)))

but as soon as I visit an org-mode buffer all of my future buffers don't have whitespace mode any more.

I thought of adding a hook to turn whitespace mode on for other major-modes but that seems like a bad way to go since I don't want to enumerate all the other possible modes.

I know that there is whitespace-mode along with global-whitespace-mode, but I'm not sure how I can use that to help here either.

Is there some other way to accomplish this that I'm not thinking of?


texts: Is there an easy way to edit all links in an org file?

texts:
I have an org file with several dozen links to various webpages. I'd like to view and edit most of the urls in this file. Is there a convenient way to do this?

In other words, does org-mode have a feature that allows me to view and edit all the links in my document in one place?


texts: Size of default face from environment variable

texts:
I'd like the size of the default face be read in an environment variable.

Currently my .emacs reads the frame size from the EMACS_HEIGHT var thanks to the following code in the (custom-set-variables ...) list:

'(default-frame-alist
    (cons
       (cons (quote height) (string-to-int (getenv "EMACS_HEIGHT")))
       (quote ((menu-bar-lines . 1) (tool-bar-lines . 0) (width . 82)))))

I tried to adapt it to "insert" a similar getenv directive into the line which sets the default face (in (custom-set-faces ...)):

'(default ((t (:inherit nil :stipple nil :background "grey80" :foreground "black"
               :inverse-video nil :box nil :strike-through nil :overline nil
               :underline nil :slant normal :weight normal :height 110
               :width normal foundry :"unknown" :family "Droid Sans Mono"))))

but didn't succeed. Or, rather, I may achieve my goal with something like

(cons ':inherit (cons nil (cons ':weight (cons 'normal (cons ':height (cons
(string-to-int (getenv "EMACS_HEIGHT")) '(:foundry "unknown")))))))

but using one cons per item looks like much ado (and a waste of parentheses).


texts: Replace clicking a menu bar option from M-` to f10 behavior

texts:
When I click on File I want to see

and not

What can I change to provide this functionality? This question didn't really get the right answer.


texts: Run some commands before and after clicking open a certain type of org-mode link file in its associated app

texts:
Whenever I click on a mp3 or mp4 org-mode link, I'd like my files to open in their associated app after running some relevant applescripts I have. I also have some scripts that I'd like to run after opening those files too.

I already have scripts to change behavior of org-mode links of certain file types but I don't know what command actually opens files in each file type's default app.
I've already got a package for running applescripts in Emacs from MELPA too, so the only part I'm missing is the command to open an org-link file in its associated app. What is it exactly?

(require 'org)

(defun my-find-file-fn (file)
"If the filename extension of FILE ends in `.txt' or `.el' or `.png', then use
`find-file-other-frame'; otherwise, use `find-file-other-window'.  The three file
extensions txt/el/png are hard-coded into the let-bound variable `regex'."
  (let* (
      ;; regexp-matchp-fn from:  https://github.com/kentaro/auto-save-buffers-enhanced
      ;; regexp-matchp-fn modified by @sds:  http://stackoverflow.com/a/20343715/2112489
      (regexp-matchp-fn
        (lambda (regexps string)
          (and string
             (catch 'matched
               (let ((inhibit-changing-match-data t))
                 (dolist (regexp regexps)
                   (when (string-match regexp string)
                     (throw 'matched t))))))))
      (ext (file-name-extension file))
      (regex '("txt" "el" "png"))
      (regex2 '("mp3" "mp4")))
        (if (funcall regexp-matchp-fn regex ext)
          (find-file-other-frame file)
          (if (funcall regexp-matchp-fn regex2 ext)
           (progn
            (apples-run-file "/path/to/my-applescript-to-run-before-opening-mp3-and-mp4-files.scpt")
            (open-file-in-default-app);;this part is missing!
            (apples-run-file "/path/to/my-applescript-to-run-after-opening-mp3-and-mp4-files.scpt"))
           (find-file-other-window file)))))

(setq org-link-frame-setup '(
  (vm . vm-visit-folder-other-frame)
  (vm-imap . vm-visit-imap-folder-other-frame)
  (gnus . org-gnus-no-new-news)
  (file . my-find-file-fn)
  (wl . wl-other-frame)))


texts: Updating `dired-directory` after renaming a file

texts:
Q:   I have a list of strings:  '("apple" "pear" "peach" "nectarine" "watermelon").  How can I replace "peach" with "plum" and maintain the same order of fruits?   [CAVEAT:  The list may be very long and the nth position of the element to be replaced will not be known at the outset.]

BACKBROUND:

I am working on implementing wdired compatibility with a dired-mode listing of files created by calling:

(dired (directory-files-recursively "/path/to/directory" "" 'include-directories))

This creates a listing of absolute paths to files and directories.  After modifying the wdired buffer, and pressing the command to finalize/commit the edits, here is what happens:

 The files get renamed correctly using a revised version of wdired-get-filename, thanks to the assistance of @Drew in a related thread:  Dired / Wdired: How to test whether a filename is relative / absolute .  [The renaming of directories (if applicable) will be dealt with by me on another day.]
 dired-readin-insert does not work correctly to populate the buffer anew because the variable dired-directory was not updated with the new absolute path of the files that got renamed.

/path/to/bin/gls: cannot access '/path/to/filename': No such file or directory

There will undoubtedly be additional hurdles to implement this new wdired feature, so I understand this will be one baby step at a time.  To resolve this particular question, I am looking for something a little fancier than delete and push/add-to-list.  Specifically, I would like to programmatically replace the old filename with the new filename and maintain the same list order.

EDIT:  Here is a link to the bug-report seeking an enhancement of wdired and dired:  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=31601


texts: The Emacs eshell alias of CMake doesn't recognize path correctly?

texts:
I'm using the Emacs eshell's alias feature to make an alias to the cmake command like below:
$ alias cmake 'cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1'

The alias is created correctly, here is the output of running which cmake inside eshell:
$ which cmake
cmake is an alias, defined as "cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1"

However, when running this alias cmake inside my project, it doesn't recognize the input path correctly. For example, when running cmake .., it seems unable to interpret the .. path.
Here are the detailed steps to produce this error:
$ cd my-project     # the CMakeLists.txt is stored at the root folder of this project
$ mkdir build
$ cd build
$ cmake ..          # running the cmake alias
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.

CMake Error: The source directory "/home/trungtq/workspace/ocaml/discover/llvm-normalizer/build" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

Does anyone know how to fix this problem?
Thank you very much!


texts: Fortran mode: Moving with M-f or M-b suddenly stopped working

texts:
I was using fortran-mode for some time without problem, but recently the bindings M-f and M-b stopped working.

It seems that they are not bound to the forward-word and backward-word moving commands anymore, but instead to some commands defined in a file called ftnchek.el (this is what C-h k told me about them), which is apparently a "fortran 77 syntax and semantics checker". In this file, I found these:

    ; I'm not sure I like these but nobody's complaining.
    (define-key fortran-mode-map "\C-x`" 'ftnchek-next-error)
    (define-key fortran-mode-map "\M-s" 'ftnchek-subprogram)
    (define-key fortran-mode-map "\M-b" 'ftnchek-buffer)
    (define-key fortran-mode-map "\M-p" 'ftnchek-previous-subprogram)
    (define-key fortran-mode-map "\M-n" 'ftnchek-next-subprogram)
    (define-key fortran-mode-map "\M-f" 'ftnchek-first-executable)
    (define-key fortran-mode-map "\M-h" 'ftnchek-what-subprogram)

which I think causes the problem.

So I have two questions:

Why do you think these keybindings were working just like in text-mode for some time and then started to run the above checking functions?
What do you think is the best to do to have the classical behavior of M-f and M-b, while still accessing the above checking functions? If you think I should modify the part of ftnchek.el I am displaying above, do you have any suggestions on new keybindings?

(Note: I am not able to tag this question with "fortran-mode")


texts: How can I enable auto-save based on filename?  I use a naming convention (a prefix to the filename) for my notes and I'd like to enable auto-save for those files.


texts: Set a title to an Emacs instance running in a terminal

texts:
On Ubuntu, I usually open more than one Emacs instances in the same time (for frontend and back development). These instances always by default take the name "Terminal" as a title as shown on this screenshot:

Is there a handy way to change that title?

Emacs is running inside a Gnome terminal.


texts:
I want my emacs to automatically upgrade all packages under certain conditions.

What's the best way of doing this?


texts: Org-export: How to include a pregenerated HTML file when exporting org to HTML?

texts:
I'm rewriting my personal home page as an org-file that I export to HTML.  In this HTML document, I'd like to include the content of some pregenerated HTML fragments stored in other files (my list of publications as generated by bibtex2html).

Here is an example document:

* My personal home page
** Articles
[insert HTML file with list of articles here]

** Posters
[insert HTML file with list of posters here]

I tried using #+INCLUDE: but that escapes all HTML and hence shows the HTML source in the resulting web page not the rendered HTML fragment.

I also tried the following

#+BEGIN_HTML
#+INCLUDE: "file.html"
#+END_HTML

but the #+INCLUDE directive is not interpreted inside the HTML block.

It seems like there should be an easy way to achieve this but I can't seem to find it.


texts:
When I was researching the best way to merge a feature branch with a lot of WIP commits I came across squashing and rebasing however when looking how to do this in magit I found this sentence in the magit documentation on the magit-merge-squash command:

  Instead of this command you should probably use a command from the apply popup.

Why is that the case? Is it considered bad practice? If so what would be the correct way?


texts: How to turn off autocompletion for numbers (and numbers only) in company-mode in spacemacs

texts:
When typing a number in spacemacs all kind of numbers are being suggested. I can autocomplete them with enter. I like this behaviour in the case I'm typing words (made up of letters). But I don't want this behaviour when I'm typing numbers.

Often I have to type a number at the end of a line. So for instance, when I want the number 10 but type enter in order to go to the next line, the 10 I type expands to 1001004005438142.

To avoid the 10 being expanded, I can type a space and after that an enter. That's the way I handle this at this moment.

However I just don't want numbers to automatically expand.

What functions or strings can I put into my .spacemacs (or init.el) to prevent numbers, and only numbers, from being suggested (and consequently being expanding when I type enter)?


texts: How can I make terms searched with `*` or `#` populate the search history?

texts:
In my attempt to have * and # work in Spacemacs as they do in Vim, I've followed the solution posted at this question.

Those keys now work, but there's one hurdle more to overcome: the searched term does not populate the search history.

As an example, suppose you:

do /aaa
position yourself over another word, say "bbb" and hit *
hit n

Spacemacs will search for "aaa" rather than "bbb".
Is there a way to fix this behaviour?


texts: gnus, gmail and mbsync..do i need dovecot?

texts:
I'm trying to setup using gnus for mail using gmail.

I have a solid mbsync installation which saves my mails in a maildir folder.  I've been reading lots of guides, including very up to date ones, and all of them seem to use dovecot in such a setup.  Why is dovecot necessary?  Other mail apps in emacs can just read a maildir folder (mu4e, notmuch, etc).

Can one just read a maildir directly into gnus?


texts: How can I change what happens when I click on a pdf-tools link?

texts:
I read pdfs with pdf-tools, but I think what I'm asking may apply to more than pdf-tools alone.

In any case, as an example, some research paper pdfs have references with clickable links - say a link to the journal as in: http://journal-name.com/article-id. When the link is clicked, the browser opens up and redirects to the URL specified in the link.

So far so good. What I would like to know though, is if would be possible to have links redirect somewhere else. Instead of going to the journal website, I would like to know whether clicks could redirect to https://my-website.tw/http://journal-name.com/article-id instead (perhaps only when the link matches a regexp).

How would something in these lines be implemented?

I don't even know what function to change, because calling C-h k on a mouse press seems to show me a function that is completely irrelevant to following links.


texts:
A compiled program and a source code can be interpreted differently at runtime. The issue is that some Lisp objects should not be modified because of the byte-compilation.

Emacs Lisp manual: 2.7 Equality Predicates
The Emacs Lisp byte compiler may collapse identical literal objects, such as literal strings, into references to the same object, with the effect that the byte-compiled code will compare such objects as eq, while the interpreted version of the same code will not. Therefore, your code should never rely on objects with the same literal contents being either eq or not eq, it should instead use functions that compare object contents such as equal, described below. Similarly, your code should not modify literal objects (e.g., put text properties on literal strings), since doing that might affect other literal objects of the same contents, if the byte compiler collapses them.

This does not imply that all Lisp objects are necessarily byte-compiled but the byte-compilation can change the code somehow.

Emacs Lisp manual: 17 Byte Compilation
Emacs Lisp has a "compiler" that translates functions written in Lisp into a special representation called "byte-code" that can be executed more efficiently. The compiler replaces Lisp function definitions with byte-code. When a byte-code function is called, its definition is evaluated by the "byte-code interpreter".

I think that the compiled code is read only once but may be evaluated several times.
In addition, in general, there are not only primitive objects. In the broader sense, which Lisp objects are byte-compiled? For example, are literal objects all and always byte-compiled?

Let's end with two final observations. 1. The Elisp manual shows that we can modify literal lists bound to variables. 2. Previously, lambda expressions had to be specified as functions '#(lambda ...) in order to be byte-compiled.
Note: From my point of view, a "byte-compiled object" can be a special object created because of the byte-compilation (e.g. a byte-compiled function) or any object that appears only during the byte-compilation (e.g. a constant object).


texts: Can I align all the tables in an org file from the command line?

texts:
I have some org files that I generated from a program I wrote. My program is not intelligent enough to parse the tables in these files "correctly". For example, one of my org files may look like

#+Title: hello world

* section 1

here is an unaligned table

|this |is | my |
| first| unaligned| table |

* section 2

here are two more unaligned tables

| this | is |my |
|second| unaligned |     table|

|yet|another| unaligned|
|table| to |alter|

I'd like to be able to automatically align all the tables in these files from the command line. Thus running such a command on my above file would yield

#+Title: hello world

* section 1

here is an unaligned table

| this  | is        | my    |
| first | unaligned | table |

* section 2

here are two more unaligned tables

| this   | is        | my    |
| second | unaligned | table |

| yet   | another | unaligned |
| table | to      | alter     |

Does such a command exist?

I'm aware that setting org-startup-align-all-tables to t will automatically align every table upon visiting the file but I'd like to align the tables without actually opening the file.


texts:
I'm on Windows 10 Pro 10.0.21337 (windows insider program) and installed WSL with Ubuntu 20.04.
From within ubuntu I said
apt-get update
apt-get upgrade
apt-get install emacs
dpkg -l emacs
->
||/ Name           Version           Architecture Description
+++-==============-=================-============-=================================
ii  emacs          1:26.3+1-1ubuntu2 all          GNU Emacs editor (metapackage)

after installing I could launch emacs from the ubuntu bash and from the windows start menu.
It worked fine for a while but suddenly it crashed (I was measuring the effective keyboard delay rate in emacs by keeping the space bar pressed for up to 5 s, when it crashed, so I'm sure I didn't invoke anything special)
Since then, when I start it via the start menu nothing happens. It doesn't appear in the windows task manager but ps auxww lists a running process /usr/bin/emacs with 0% CPU.
When I start it on cmd line and press Ctrl-C it prints an unreadable character and then Display :0 unavailable, simulating -nw. (after the latest update it stopped printing that message).
I renamed my .emacs and .emacs.d, uninstalled and reinstalled it (including apt autoremove), with no success.
Then I tried command line options:
emacs -Q makes no difference.
emacs --debug-init prints nothing.
emacs -nw works: it starts the text version, so only the gui version is broken.
UPDATE:
I kept two emacs processes (one started from start menu, one from cmd line) running while putting the laptop through sleep + wakeup a couple of times. Once on waking up two emacs windows were visible! On the next wakeup they were invisible again. ps still shows the two processes. This means that it's indeed a window manager problem like @jue assumed or, say, a process manager problem. I'll keep investigating.


texts:
I have a non-interactive function F to do post processing after each command. F is buffer locally hooked to post-command-hook.

Whenever F is hooked the prefix argument is eaten and the next command does not get it.

How can I preserve the prefix argument when hooking a function to post-command-hook ?

EDIT: There is no issue with the prefix argument and the function F being hooked as the selected answer shows.

My issue was that the function (let's call it A) that did not worked properly could be either called directly (which had a working behavior) or called from a push-button (in this case the prefix argument was not passed to A).


texts: How to make minor customization to emacs theme colors

texts:
I'm a fan of gruvbox, but would like to slightly change the white colors to make them less intense. Is there any easy way of changing this line:
(gruvbox-light0          "#fdf4c1" "#ffffaf")
to this:
(gruvbox-light0          "#ffd7a6" "#ffffaf")
without creating a completely new theme file?

I'm aware of this sort of solution:

(custom-theme-set-faces
 'gruvbox
 '(font-lock-comment-face ((t (:foreground "#DFAF8F"))))
 '(font-lock-comment-delimiter-face ((t (:foreground "#DFAF8F")))))

but I'd like to change the color in one place, so that everything set to gruvbox-light0 is updated.


texts: How to automatically tangle another source block to file when evaluate a source block in org-mode?

texts:
The source block what I want to evaluate (src2) need to source a file which should be the tangle result of another source block (src1). How could it make the tangle to file automatically everything time I evaluate the source block?

src1: should be tangle to file:

+begin_src tcl :tangle /tmp/compile_lib.tcl
  <some tcl code>
+end_src

src2: would be evaluated.

+begin_src sh
   vivado -mode batch -source /tmp/compile_lib.tcl    # source the file tangled from <src1>
+end_src


texts:
I use Evil mode inside Emacs to emulate vim-style editing. In the Xwindows based graphical user interface of Emacs on Ubuntu 16.04, Evil mode works perfectly.

When I launch emacs in terminal mode with emacs -nw foobar.cpp ,say I want to save a file with M-: w then I get the message in the message buffer saying M-: is not defined

However, the standard C-x C-s method of saving a file works in the terminal. How do I get the M-: behavior working in Emacs terminal mode as it does in graphical mode?