texts: Emacs can't find Node when Node was installed using NVM (again)

texts:
My question is similar to this question. I've installed node via nvm.   (executable-find "node") returns .nvm/versions/node/v15.11.0/bin/node.
Entering node on eshell drops me into a node shell. But when I enter npm in an eshell, I'm fed
/usr/bin/env: ‘node’: No such file or directory
Similarly, the command nvm returns nvm: command not found.
On a zsh terminal, the above commands work as expected. I suspect this has to do with the following line in my .zshrc:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

I can use (setenv "NVM_DIR" "~/.nvm") to set the env var, I'm at a loss per the second line.
including the line   (setq exec-path (append exec-path '("~/.nvm/versions/node/v15.11.0/bin"))) does not solve my problem.


texts: How could I change the font color on the popped out window (jedi)?

texts:
I am using python-mode and jedi for autocompletion.

(add-hook 'python-mode-hook 'jedi:setup)
(add-hook 'python-mode-hook 'jedi:ac-setup)

(require 'auto-complete-config)
(ac-config-default)
(set-face-background 'ac-completion-face "black")
(set-face-underline 'ac-completion-face "black")
(set-face-underline 'ac-selection-face "black")

The font color show up as yellow on top of a gray background, which is unreadable. Also for the selected line, gray font on top of blue is unreadable.

I want to change the font color or the background color, if its possible.

[Q] How could I change the font color or the background color on the popped out window that show up on jedi usage?


texts: Don't switch to math-mode when entering `$` in a `minted` environment

texts:
I am using AUCTeX to edit Latex files and use the minted package to highlight source-code within documents. Unfortunately the character $ is still recognized as a delimiter for a math-mode even though it is located within a minted-block and should have no special meaning whatsoever.

This totally breaks syntax-highlighting and makes emacs think I am editing in math-mode although I am not.

Is it possible to configure AUCTex in such a way as to give characters within a minted environment no special meaning? Or do I have to apply some sort of quoting to $?


texts: Configure upstream for rebasing onto master in magit

texts:
I have a forked repository. I want to configure my upstream so that I can keep my master up to date and rebase my feature branches. How can I do this?

magit-version returns Magit 20160810.653, Git 2.6.4 (Apple Git-63), Emacs 25.0.50.1, darwin.


texts:
I have always felt that emacs' rules of scope are a bit strange
and prone to contradictions.  In fact I have even attempted to file
bug reports just to be told that my interpretation of the rules of scope
was wrong,  which I always reluctantly accepted.
This time I think I nailed a contradiction caused by such rules.  In the
emacs manual page for setq (https://www.gnu.org/software/emacs/manual/html_node/eintr/Using-setq.html), it is
stated that setq is exactly the same as using set followed by a
quote, but the following two examples show that it isn't:
(progn
  (setq a "one")       ;; Global variable
  (let ((a "two"))     ;; Local variable
    (set 'a "three")   ;; Using "set + quote" affected the GLOBAL variable "a"
    a))                ;; Return local variable a

=> "two"               ;; The local variable "a" remained with its let-value "two" and was not affected by "set + quote"

Here is the second example:
(progn
  (setq a "one")       ;; Global variable
  (let ((a "two"))     ;; Local variable
    (setq a "three")   ;; Using "setq" affected the LOCAL variable "a"
    a))                ;; Return local variable a

=> "three"             ;; The local variable "a" was changed by setq

My question is thus:  Am I once more misinterpreting the rules of scope
or have I really found an inconsistency in these rules?
Perhaps I should add that the above code was run with lexical binding enabled. Otherwise I believe there is no inconsistency

My emacs version is: GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2021-03-26


texts:
I'm using Emacs to write ocaml programs, and the automatic indentation works fine : suppose I write if in the middle of a line, then skip a line and write then ; the keyword then is automatically aligned with my if.

But if I later decide to add some code before the if, and the position of the if thus changes, then remains aligned with the previous position of the if until I manually add (and immediately remove) a lineskip on the line that has my then so that the indentation is recalculated.

Is there a way to ask Emacs to reindent all lines in my document without having to add-and-remove lineskips everywhere to force Emacs to recalculate the correct indentation line by line?


texts: How do you use the eieio-persistent class to serialize a set of objects?

texts:
I am trying to use the eieio-persistent class to make persistent objects. My goal is to store many objects in a file.

I am not sure how to achieve this though. If I use this code, I do get a persistent object saved in test.db, but (perhaps predictably) the second save overwrites the first one.

(defclass animal (eieio-persistent)
  ((type :initarg :type)
   (file :initform "/Users/jkitchin/Dropbox/org-mode/test.db")))

(let ((a1 (animal :type 'mammal)))
  (eieio-persistent-save a1))

(let ((a1 (animal :type 'rodent)))
  (eieio-persistent-save a1))

Is there a way to save a list of these "animals" using the eieio framework? I would prefer not to create individual files for each object (I am anticipating thousands of objects later that need to be read in). Ideally, there would be another class that had a list of these animal objects in a records field.

Something like this is close

(defclass animal-db (eieio-named eieio-persistent)
  ((id :initarg :id)
   (file :initform "/Users/jkitchin/Dropbox/org-mode/test.db")
   (records :initarg :records :type listp))
  "Base db for animal class")

but the list in the records doesn't appear to be actual objects, when I read the code back in, but code that needs to be eval'd to get the object.

Any ideas?


texts: How to setup a private package repository?

texts:
I've written several packages for GNU Emacs, but they are useless outside of my company's environment. I want to be able to share the packages with other developers from my company. I also want the packages to be easily discoverable via package-list-packages.

I think that private repository will solve my problems, but I can't find any manual on personal archives setup. As far as I understood, the Elisp info manual suggests plain directories and package-upload-file, but I don't think it plays nicely with concurrent package updates. Are there any other options that are relatively easy to setup?


texts: disable table mode using either #+BEGIN_EXAMPLE or ‘:’ literal line , but insert latex math block $ ... $

texts:
I’m trying to typeset a grammar in org markup, but want to use latex symbols in the grammar:
a ->  hello
   |  $\neg$ world
   |  universe

•  Now, without using #+BEGIN_EXAMPLE or : literal-line prefix, the | syntax gets interpreted as a table.
•  The issue is that using either solution causes the Math latex statement to no longer be recognized.
Thanks


texts: How to go to end of match using search-backward-regexp?

texts:
I am trying to match a regex using this code

(search-backward-regexp "\n[\t\n ]*?\n" nil "NOERROR" 1)

search-backward-regexp documenation says

  Set point to the beginning of the match, and return point.

How can I set point to end of match?


texts:
I have the following for ridding of the toolbar on startup in graphical mode in my init configuration:

(if window-system
    (tool-bar-mode -1)
)

the issue:

it works fine (albeit slow...see this post) when starting emacs but does not work with the emacs --daemon , starting emacsclient c starts a graphical client with toolbar ( I want without). Does emacs graphical client require a seperate code to the if window-system?

I run:

emacs 25.3 on Linux manjaro 17.1.5 Hakolla


texts: How to count the number of lines in the region?

texts: Is there a command similar to count-words-region to count the total number of lines of a selected region?


texts: How to check if a list item has a checkbox in orgmode

texts:
I am attempting to write a convenience function that would, on an item in an orgmode list, insert a checkbox if there is none, and do nothing otherwise.

The question is how would I be able to test for the existence of a checkbox in a list item?

I'm aware of testing for a list item via org-in-item-p, but am unable to find a similar predicate for checkboxes.

Any help would be appreciated. Thanks.


texts: Space and line-end indicators stay after switching off whitespace-mode

texts:
When I switch on whitespace-mode I get all the indicators and color for showing superfluous whitespace. So far so good.

But when I switch off whitespace-mode the space indicator . and the line-end indicator $ stay.

How can I switch them off as well, so that the buffer looks normal again?


texts: sectioning in org-mode to beamer does not work

texts:
I am trying to subdivide my presentation further into section and according to the org docs, setting
#+BEAMER_FRAME_LEVEL: 2
should allow for top-level headlines to be interpreted as sections, whereas not the second level headlines, i.e. ** are defining individual pages. However, in my minimal example below, setting the value from 1 to 2 does not make any difference. What am I missing here?
#+TITLE: Abandon all hope

#+startup: beamer
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [bigger]

#+BEAMER_FRAME_LEVEL: 2

* First page
** Stuff
larifari
** second stuff
larifari
* Second page
** fdjsfsd
larfdfj
** fjs
iiinfdnf


texts: How to keep the right done tag while updating statistics?

texts:
I have defined an additional TODO state in my org-mode file.

#+SEQ_TODO: TODO(t) WAIT(w) HAZY(h) | DONE(d) FINE(f)

DONE means "I am ready" and FINE means "It is accepted".

I use hierarchical TODOs and C-c # to update the headlines. This is an example.

** DONE [#1] Headline [3/4]
   SCHEDULED: <2016-01-11 Mo>
*** Description
*** FINE First task
    CLOSED: [2016-01-15 Fr 10:57]
*** FINE Second task
    CLOSED: [2016-01-15 Fr 15:33]
*** FINE Third task
    CLOSED: [2016-01-15 Fr 16:13]

When I update the headline org-update-statistics-cookies does not mark the headline as FINE. Even worse: when I manually set the state of the headline to FINE it gets changed back to DONE.

My intention is to mark the headline as DONE as long as there is a child marked DONE and if all children are marked with FINE the parent should also marked as FINE. Later on I want to define an agenda view containing everything but those marked as FINE.

I tired to find the right position in the source, but I am a bit lost. The function org-update-statistics-cookies calls org-update-parent-todo-statistics and I think this is a good candidate to cause the error, but I am not sure, because I still did not find the exact line where the DONE gets written.

Can anybody help me to find it?


texts: org-mode agenda refile doesn't provide buffer options

texts:
For a year or so I've used Bernt Hansen's good org-mode workflow and init file, with a couple small adaptations. http://doc.norang.ca/org-mode.html

I'm almost done setting up org-mode on a new computer (new job) but I can't get refile working properly.

From the agenda, when I use C-c C-w for single refile or m B r for bulk refile, I get the Refile to: prompt as expected. But there are no target options displayed.

On my previous computer, I had a nice list of target locations to select from (similar in look+functionality to C-x b, but the Refile to: list also included headlines ... I'm not sure what this is called ... IDO?). I would like to have this functionality again.

This part of init.el looks correct:

; Targets include this file and any file contributing to the agenda - up to 9 levels deep
(setq org-refile-targets (quote ((nil :maxlevel . 9)
                                 (org-agenda-files :maxlevel . 9))))

and IDO is turned on:

; Use IDO for both buffer and file completion and ido-everywhere to t
(setq org-completion-use-ido t)
(setq ido-everywhere t)
(setq ido-max-directory-size 100000)
(ido-mode (quote both))
; Use the current window when visiting files and buffers with ido
(setq ido-default-file-method 'selected-window)
(setq ido-default-buffer-method 'selected-window)
; Use the current window for indirect buffer display
(setq org-indirect-buffer-display 'current-window)

Where can I look next to troubleshoot this?


texts: How to change shell-script-mode indentation not to use tabs?

texts:
To reproduce my issue, open your .bashrc or a .sh file and type the following:

if
    while
        echo

The if has no indentation. Good.

The while has the default four spaces of indentation. Good.

The echo has a tab character for indentation. Why?

Are there any hidden values I can set to prevent what should be eight spaces from becoming a tab? I find nothing in M-x customize.

Messing with the following does not help:

'(sh-basic-offset 4)
'(sh-indentation 4)

When I use M-x smie-config-show-indent, the result is this:

Rules used: :elem basic -> 4, :after "while" -> nil

So it doesn't seem like SMIE is responsible. I think shell-script-mode is automatically converting eight spaces to tabs. This isn't happening in any other mode.

This occurs with or without electric-indent-mode.


texts:
I recently discovered helm-ag, and like its functionality. For some reason, though, I have to enter the pattern to search and then press Return to actually get the helm-ag buffer to appear in helm-mini. Is this something that needs to be manually configured? Part of my setup for helm consists of

(require 'helm-ag)
(global-set-key (kbd "C-c s") 'helm-ag-this-file)
(global-set-key (kbd "M-x") 'helm-M-x)

and I was hoping that this would be enough to get things to appear in helm-mini like the rest of the helm commands (like helm-M-x does without any apparent additional setup).


texts: How can I tell align-current to align multicolumn cells properly?

texts:
Can align-current also handle multicolumn cells properly?
IT does not in my case, you can see in the following example, that the 2 columns called "Col" are placed above cell "c" in the editor after align-current, but they would have to be placed above "e" and "f" :

source-code:

\documentclass{article}
\usepackage{tabularx}
\begin{document}

  \begin{tabularx}{12cm}{|p{3cm}|X|X|X|X|X|}
  \hline
  Long text & \multicolumn{3}{X|}{Very-verylong text} & Col & Col       \\
\hline
       a    & b                                       & c   & d & e & f \\
    \hline
        a   & b                                       & c   & d & e & f \\
        \hline
\end{tabularx}
\end{document}

aligned source text in the editor (Aquamacs):

pdflatex output

How can I solve that? I have large tables with many columns and many multicolumns in the headings and it is absolutely confusing if those headings are not in the right place!

Remark: I'm currently using Aquamacs 2.5, but I assume that this problem is not bound to Aquamacs as it also happens if I use emacsin the terminal and try the same thing.


texts:
I am using emacs web-mode, and the tabbing in JS files seems to be acting strangely.

I have tab set to indent 2 spaces, but when the indent reaches 8 spaces, web-mode turns them into a tab, and then continues to tab 2 spaces until in reaches another 8, and converts that into another tab, etc.

Can I stop this from happening and tell emacs/web-mode to only ever indent spaces?

EDIT:

Here is a short nested function example:

(function() {
  function() {
    function() {
      function() {
    function() {
      // Indenting problem.
    }
      }
    }
  }
})()

It's obviously showing up fine in Emacs, but you can see the indentation problem here.

I will note here that this also occurs in javascript-mode.


texts: Is there a way to underline symbol under cursor?

texts: I want to highlight somehow symbol under cursor, is there a way to customize font for that current symbol? Ideally I want to add underline with some color to it, or maybe change bg color of text, is there a package for that or specific default font?


texts: Search and replace with case preservation and plurals

texts:
Is there a way (or package) to search and replace code like:

class Account
  def list_accounts
  end
end

to

class Company
  def list_companies
  end
end

Basically I want to replace account(s) with compan(y/ies)

Vim does this with Subvert


texts:
For replacing org-html-format-latex with auctex preview (or more correctly texfrag) it would be nice to run auctex preview synchronously.

The code of auctex preview contains several alternatives where TeX-process-asynchronous is taken care of.
Nevertheless, if one sets TeX-process-asynchronous to nil TeX-inline-preview-internal fails.
The most obvious reason is that TeX-run-command returns the process status instead of a process id and auctex tries to set the coding system for that "process".
If one skips the coding system issues by adding a check for TeX-process-asynchronous one gets the next error in preview-TeX-inline-sentinel and that goes on and on.

Is this a bug of auctex preview or has the support of synchronous auctex preview been dropped or even never fully been implemented?

Version info:

emacs: 25.3.1
auctex: 11.92.0


texts: Repeating characters in `python-mode.el` shell interaction

texts:
I experience strange behaviour when using python-mode. When sending characters to the shell using C-c C-e, the first string works well. After that, the characters start repeating, in a manner that is best understood by looking at the screenshot below. Now what is also strange is that this behaviour is also present in the minibar.
If I start emacs with emacs -q this doesn't happen. I'm looking to find what mode or setting is causing this, but I'm not knowledgeable enough to guess where to look.
The minor modes that are switched on are these:
Async-Bytecomp-Package
Auto-Composition
Auto-Compression
Auto-Encryption
Blink-Cursor
Company-Quickhelp
Company-Quickhelp-Local
Counsel
Counsel-Projectile
Delete-Selection
Display-Line-Numbers
Doom-Modeline
Eldoc
Electric-Indent
File-Name-Shadow
Font-Lock
Global-Eldoc
Global-Font-Lock
Global-Git-Commit
Global-Magit-File
Ido-Everywhere
Ivy
Line-Number
Magit-Auto-Revert
Mouse-Wheel
Org-Roam
Override-Global
Projectile
Pyvenv Pyvenv-Tracking
Recentf
Shell-Dirtrack
Tooltip
Transient-Mark
Which-Key
Window-Numbering

The relevant configuration I guess in my init.el
(use-package python-mode
  :ensure t
  :custom
  (python-shell-interpreter "ipython3")

If I use python for interpreter, this doesn't happen, which leads me to believe there is something wrong with the regexes used for determining the prompt. However, why does the minibar show this as well? Perhaps something else with the code that drives the inferior mode?
I would be grateful and will accept some pointers from someone that understands a bit better how this works, a plausible cause and explanation for this behaviour.


texts: Choose files to stage of a new directory with magit

texts:
If you create a new directory, its files won't show up with magit-status, only the new directory is in the list of Untracked items.

Currently I have to magit-stage-item the new directory and then remove unwanted files from the stage area.

Is there any way to choose which files to stage from a new directory?


texts: How do I get ein to find conda packages?

texts:
I'm trying to use ein to edit a jupyter notebook. I used conda to install the 'turicreate' package in a virtual environment and activated it. When I run the regular browser based jupyter notebook command everything works. Only inside ein does it not work -- I can open the notebook, but when I try to import turicreate it complains it can't find the module.

First I tried:

(setq ein:jupyter-default-server-command (format "%s/anaconda3/bin/jupyter" (getenv "HOME")))

This got ein to open the notebook, but the import failed. I figured the conda env wasn't propagating so I opened a shell, activated the environment and did:

$ env | grep -i py
$ env | grep -i conda

To see if activating just set env vars. So then I tried:

(setenv "CONDA_DEFAULT_ENV" "virtual_environment_name")
(setenv "CONDA_PREFIX" (format "%s/anaconda3/envs/virtual_environment_name" (getenv "HOME")))

I shutdown all jupyter servers and tried ein:run again. Still no dice.

So then I wrote a shell script:

#!/bin/bash

conda activate virtual_environment_name
$HOME/anaconda3/bin/jupyter "$@"

And set:

(setq ein:jupyter-default-server-command (format "%s/jupyter-with-anaconda.sh" (getenv "HOME")))

And it STILL can't find the module. At this point I'm at a loss. I have no idea how the environment state gets to the browser based jupyter so I don't know how to duplicate it for ein.

Any ideas?


texts:
I would like to change all occurrences of a string (say string1) with another string (say string2) and vice-versa. To be precise I have a long document and these strings occur many times. What I currently do, is to replace string1-->string3, then string2-->string1 and finally string3-->string2.

I am wondering if there is already a function in emacs which does this.  Other solutions are welcomed.

Edit: This is actually a duplicate of the question linked in the comment. But the problem is that the accepted answer of that question does not always work (see the comment below). I think it is better to wait until the author of that accepted answer corrects his/her answer or some other solution comes out. Secondly before posting my question, I googled the question and that question did not show up. I think having two duplicate questions is sometimes useful since they use different wording and if a user find the duplicate one, he/she can find the right one.

Edit 2: The accepted answer of Search/replace-like feature for swapping text seems to be fine now.


texts: Twilight times in addition to sunrise/sunset?

texts:
The sunrise-sunset function from solar.el computes sunrise and sunset. I would also like to have a function that computes the end/beginning of

civil twilight (center of sun 6 deg below horizon)
nautical twilight (center of sun 12 deg below horizon)
astronomical twilight (center of sun 18 deg below horizon)

Does anyone know of elisp-code (or a package) for computing said times?

Edit: There seem to be a solution within solar.el: The function solar-sunrise-sunset calls the function solar-sunrise-and-sunset with a HEIGHT of -0.61 degrees (half the apparent diameter of the sun). Using a HEIGHT of -6 degrees should give the end/beginning of civil twilight, and similar for the other.


texts:
So I have opened a buffer where a python script is loaded.
I do M-x load-library RET and after that realgud:pdb. Then I get pdb /path_to_script/main_func.py which is ok. After pressing enter I get the error (file-error "Searching for program" "No such file or directory" "pdb")

So how do I get around this. From what I understand and have seen so far pdb is not a standalone executable. It's a module that is imported into the code directly. But from what I can get here there are no further steps required to run it (no import as well?). So what am I missing?

I'm on OS X and emacs 25.2 (9)


texts: While it is easy to run the whole test suite with projectile-rails, this takes too much time. I'd like to be able to run the current test (i.e., the test point is located in) with a shortcut. Is this possible?


texts: Making an image (ie. image-mode) auto reload changes from disk

texts: I have an image generated by plantuml which I open in an Image mode buffer. I want to use Auto-Revert mode so it auto-refreshes, but it doesn't seem to work on Image mode buffers for some reason. Is there something I'm missing?


texts: How delete folder named "build" in all subfolders?

texts:
Emacs 26.1, Dired+, Windows 10

Suppose I has the next dir tree:

myproject
myproject\app\
myproject\app\build
myproject\app\src
myproject\lib\build
myproject\lib\src
myproject\lib2\build
myproject\lib3\build
myproject\lib3\src

I want to delete folders build in all subfolders. After delete the result must be like this.

myproject
myproject\app\
myproject\app\src
myproject\lib\
myproject\lib\src
myproject\lib2\
myproject\lib3\
myproject\lib3\src

Is it possible? And is it possible in dired mode?


texts: I am on MacOS High Sierra, iterm2; I cannot find how to display images in org-mode. My term supports image display as imgcat works well within my shell. When I try to open the image link in emacs it returns Display not supported then the verbose is gibberish. I don't want use GUI emacs. I have tried to install Spacemacs but it does not solve the issue. I have tried to turn on iimage, imageMagick without luck. Any idea?


texts: Org-mode table recalculation with a remote() formula using calc?

texts:
Can I make table2 automatically recalculate a remote() formula when I modify data in table1?

I have the below tables and the first table is automatically recalculated when I press TAB (thanks to the "#" in the first column), but the second one it's only recalculated when move my cursor over it and press TAB in there as well.

I would like to have it recalculated when I change (TAB) the first table.

#+NAME: table1
| # | + Units | value | value2 |
|---+---------+-------+--------|
| # | unit1   |  3110 |    295 |
| # | unit2   |       |        |
| # | unit3   |       |        |
|---+---------+-------+--------|
| # | - Units | value | value2 |
|---+---------+-------+--------|
| # | unit1   |   -40 |        |
| # | unit2   |  -105 |        |
| # | unit3   |   -26 |        |
|---+---------+-------+--------|
| * | TOTAL:  |  2939 |    295 |
|---+---------+-------+--------|
#+TBLFM: @9$3=vsum(@-1..@1);EN::@9$4=vsum(@-1..@1);EN

#+NAME: table2
| # | TOTAL + |  3405 |
| # | TOTAL - |  -171 |
#+TBLFM: @1$3=vsum(remote(table1,@I$3..@II$3))+vsum(remote(table1,@I$4..@II$4));EN::@2$3=vsum(remote(table1,@III$3..@IIII$3))+vsum(remote(table1,@III$4..@IIII$4));EN

I am aware that it might be possible using elisp code but would like to have it work with calc syntax, if possible.


texts: Should K&R indentation work in C++ code?

texts:
Given the following file, named as x.cpp I get the following unexpected indentation behavior:

#include <stdio.h>
class X {
public:
     X()
          {  // <-- Why the indent?
               printf("Hello!");
          }
};
int main() { X x; }

// Local Variables:
// c-file-style: "k&r"
// End:

I know that this file is not valid C source, but if I rename the file to x.c and re-indent, I suddenly get the expected indentation:

#include <stdio.h>
class X {
public:
     X()
     {  // <-- Looks good
          printf("Hello!");
     }
};
int main() { X x; }

// Local Variables:
// c-file-style: "k&r"
// End:

Obviously, the problem is a difference in the way the file is parsed syntactically in the two different major modes.  In C mode, the brace on line 5 is seen as substatement-open, while in C++ mode it is seen as inline-open.  Since the emacs definition of "k&r" style doesn't specify an indent for inline-open it defaults to something silly.

My question then, is whether it is reasonable to expect that "k&r" indentation style should work in C++.  In other words, should I file an emacs bug for this?  Or am I missing something that would make this work as expected?


texts: How to archive an org-mode subtree along with its parent headlines

texts:
Let me start out by saying I've seen various attempts to address questions similar to mine, but none of them handle the things I'm looking for.  Here is an example of what I'm looking for:

Say I start with an org-file that looks like:

#+ARCHIVE: ::* Archived

* Foo
  * Tasks
    * Task1
  * Thoughts
    * Thought1
    * Thought2

* Archived

Now I put the point (i.e. cursor) on Thought1 and run org-super-archive (the magical command I'm hoping to find).  The result should be:

#+ARCHIVE: ::* Archived

* Foo
  * Tasks
    * Task1
  * Thoughts
    * Thought2

* Archived
  * Foo
    * Thoughts
      * Thought1

Now I move the point to Thought2 and again run org-super-archive, which should give me:

#+ARCHIVE: ::* Archived

* Foo
  * Tasks
    * Task1
  * Thoughts

* Archived
  * Foo
    * Thoughts
      * Thought1
      * Thought2

So the basic operation I'm seeking is the ability to archive a subtree to whatever target location is specified with #+ARCHIVE (or org-archive-location) where (1) the full path of the archived subtree is mirrored beneath that target location, and (2) the subtree will be merged into an existing path under the target if an appropriate path already exists.

As an added bonus, it would be nice if it were possible to choose whether or not the "full path" of a subtree to be archived will include the org-file name as the root of the path.  This would be useful in cases where you archive from multiple org-files to a single archive.org file.


texts: How to quote for multiple levels of macro expansion

texts:
I'm new to Emacs and think I ran into some macro expansion problems. There's a function solarized-with-color-variables which is a macro that creates local variables using let* and then expands the macro body parameter inside the let* body so that it has access to these variables.

At one point I need to setq a variable to a value consisting of a list, the first element of which should take on the value of one of these variables, green. Normally I did this like this:

(setq some-var `(,green box))

However, it seems that after switching to using use-package.el's use-package macro, it seems like I'm in multiple layers of macros now, such that the above now expands one more time to:

(setq some-var (green box))

That is, it attempts to call green as a function, which it's not; it's a string.

I'm not sure how to go about fixing this, or how I should proceed. My guess is that I have to basically wrap it in another layer of quotes so that the extra expansion leaves it as is, but being new to Emacs Lisp I'm not really sure how to do this. I tried a couple variations of quote and list to no avail.

;; use-package is a macro
(use-package solarized-theme
  :ensure t
  :config
  (load-theme 'solarized-light t)

  ;; solarized-with-color-variables is a macro
  (solarized-with-color-variables 'light
    (custom-theme-set-faces
     'solarized-light
     `(show-paren-match ((,class (:foreground unspecified
                                  :background ,base02
                                  :weight normal)))))

    ;; I wanted to use with-eval-after-load but that's also a macro
    (eval-after-load 'evil
      (progn
        (setq some-var `(,green box))))))

Edit: I've come to realize that it is the eval-after-load function I'm using.

If I have this:

(solarized-with-color-variables 'light
    (setq evil-emacs-state-cursor `(,red box)))

Everything works. But if I put that inside of eval-after-load or vice versa, it breaks:

(eval-after-load 'evil
    (solarized-with-color-variables 'light
        (setq evil-emacs-state-cursor `(,red box))))

It says that the value of red, "#blah", is not a valid function. I imagine that it's expanding macros twice, once for solarized-with-color-variables so that it yields:

(setq evil-emacs-state-cursor '("#blah" box))

And then again (?):

(setq evil-emacs-state-cursor ("#blah" box))

Then when attempting to evaluate it it tries to use "#blah" as a function, which it's not. Using the code from my own answer actually is giving me problems too, I guess it's not exactly the same as the value I set manually which is '("#blah" box):

(setq some-var `(list ,green 'box))


texts: setq with lambda argument sets symbol's variable cell (or) function cell?

texts:
(setq callback (lambda ()
         (message "hai i am a lambda")))
(funcall callback)

(setq const-val "hai, i am a const")
(message const-val)

prints as

hai i am a lambda
hai, i am a const

Both of them are working perfect. that raises question about setq behavior. Does it put the argument value in the symbol's function cell (or) variable cell?


texts:
How to suppress the interpretation of double brackets in org mode?

Some of my text heavily used the double brackets but org-mode defined it to be links. Can I suppress the interpretation of double brackets, or more conveniently, temporarily suppress it where I do not need it to be interpreted as links.

I've tried quote (~~ ==) it as code but it does not work.

The only way I found is to embedded them into an EXAMPLE or SRC.

Are there any other methods, maybe some OPTIONS?

Thanks very much!


texts: Visualise keyboard macros (converting them to human readable key names)

texts:
I often find useful/nifty kmacros on the web, like (kmacro-exec-ring-item (quote ([return 3 16 14 5 return 21 3 46 return 24 98 return] 0 "%d")) arg). Being a curious guy I am, I usually want to know how they do what they do.

Given the (kbd) function, which can convert a string like "C-x C-c" to the internally used key codes (that, AFAIK, are used by kmacros), is there a reverse function for this? Can I get a human readable representation of a keyboard macro?


texts: Emacs takes a very long time to read/save to the clipboard

texts:
Sometimes emacs takes a very long time (+ 30 seconds) to read from or save to the system (Linux) clipboard. The entire emacs session hangs while it does this and I can't cancel it with C-g or ESC ESC ESC or anything. This seems to happen at random, but whenever it does happen, it tends to happen more frequently until I restart emacs.

What could be causing this behavior? Where should I start? I haven't changed the default values of x-select-enable-clipboard (t) or any other clipboard-related variables (to my knowledge)...


texts: How to make "completion buffer" as single-column

texts:
Is there any way that thecompletion buffer shows every item in a single line. By default it arranges the items in several columns. (Try to do M-x f <TAB> to see what I mean).

In general what are the variables which control the appearance of this buffer?


texts: Configuring the number of buffers saved by ido, using ido-use-virtual-buffers?

texts:
I really love the ability to quickly navigate to files opened in old editing sessions that desktop provides.  However, there are a few things I don't like about it so I'd like to stop using it if possible, but I'm not quite there yet.

What I don't like about desktop:  Note neither of these would be a problem if buffers were merely easily re-openable, rather than immediately re-opened (as desktop-change-dir does):

Slow startup with large numbers of buffers
A tendency to make it harder to diagnose problems in my emacs configuration, because of side-effects from opening buffers

What I'm trying to use instead of desktop:

ido-use-virtual-buffers: This ido feature keeps a list of closed buffers.  When using ido to switch buffer, the closed buffers show up too (with a different face and different prioritization).
saveplace to save point (cursor position) in buffers
savehist to save minibuffer history

This is all great, except that ido is only saving a small number of buffers for me in ido.last.  How can I have several hundred buffers saved by ido across emacs restart, and have them saved whether they are closed ('virtual') or not?

Customizing ido-max-work-file-list doesn't seem to have any effect for me. -- actually it does, see answer

I'm aware of projectile and use that too, but this is a bit different.  I'm also aware of recentf, but I'd prefer to stick with ido-use-virtual-buffers, because aside from lack of persistence across emacs sessions it works perfectly for me.


texts: Ubuntu/Debian preempting me and running code before me

texts:
I'm on Ubuntu 14.04, with:
GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7) of 2014-03-07 on lamiak, modified by Debian and have discovered something disturbing/annoying.

I have been trying to use the latest version of CEDET via el-get but kept getting the error of Emacs' built-in CEDET has already been loaded!  Restart Emacs to load CEDET from el-get instead. This was strange since it happened even after I commented everything in my .emacs out except for el-get code. Upon starting up with --debug-init, I saw that code is being running from /etc/emacs/site-start.d/. This is before my .emacs even gets a chance to respond. I'm guessing that something in there is doing a (require 'cedet), or at least a provide.

What can I do in this situation? Do I need to recompile emacs? Or skip the apt-get version all together and build from source? And how is it possible that the emacs binary is loading code before the .emacs? Is there some kind of meta .emacs? Or was this some kind of build flag during compilation?

EDIT: I got some info from apt-cache show emacs24-el

EDIT2: Got more relevant info from https://www.debian.org/doc/packaging-manuals/debian-emacs-policy


texts:
Org-mode's default during HTML export is to put the author in the postamble at the bottom of the page.

But I would like to export a paper like document with the author between the title and the abstract. Is it possible somehow to place the author after the title?

And is it possible to label the abstract as an abstract? I have used the delimiters

#+BEGIN_abstract
...
#+END_abstract

to mark the text as the abstact but it is rendered just as a normal paragraph (no blockquote like indent). Is it possible to get the right indent for the abstract and a localized label?


texts:
I am running emacs on Windows. I've been using the right alt key as my meta key for just about everything and it works except for M-< and M->

When I attempt M-< I get a message in the mini-buffer that says "Marker stack is empty"

M-> seems to initiate a prompt of some kind for a tags related command "Visit tags table (default TAGS):" and I then have to C-g out of that.

I feel like I'm missing something really simple but I haven't turned up anything on here or google based on the results I'm getting.

Thanks.


texts: mac osx emacs terminal `C-M e` not works but `C-M a` works

texts:
in mac osx 's terminal.app, open emacs.
key binding C-M a works, will call c-beginning-defun
but, C-M e does not work: nothing is displayed, and C-h k for this key also shows nothing.


texts: Making sure that a pair of functions is executed even if C-g is pressed in the middle

texts:
Based on the documentation, I am trying the following:

(let ((inhibit-quit t))
    (my-fun)
    (y-or-n-p "Prompt")
    (cancel-effects-of-my-fun))

Here, my-fun performs changes to configuration and cancel-effects-of-my-fun restores the configuration to its original state. I need to make sure that (cancel-effects-of-my-fun) is evaluated even if the user presses C-g during the evaluation of (y-or-n-p "Prompt"). The code above does not do the job. In fact, even setting inhibit-quit globally does not have any effect. I tried (setq quit-flag nil), but that did not make a difference either. What am I missing? Is there a more idiomatic way to achieve what I am trying to achieve?


texts:
I want to find the IP addresses of all network interfaces in an elisp program.  I tried this:

  (mapcar
   (lambda (if)
     (cons (car if) (network-interface-info (car if))))
   (network-interface-list))

However, when a network interface has both an IPv4 and an IPv6 address, the above only lists the IPv4 address.  Is there a way to access the IPv6 address from elisp? (I'd rather avoid parsing the output of ifconfig.)


texts: command works with M-x but gives "Wrong type argument: commandp" when calling through key binding

texts:
I wrote this command and key binding to use with cider for Clojure development:

(defun reload-and-eval-in-repl ()
  "Set the ns of the repl to the one in the current buffer, then eval the region of the whole buffer in the repl and switch to it."
  (interactive)
  (cider-repl-set-ns (cider-current-ns))
  (if (region-active-p)
      (cider-insert-region-in-repl (region-beginning) (region-end)))
  (cider-load-buffer-and-switch-to-repl-buffer))

(define-key clojure-mode-map (kbd "s-e") 'reolad-and-eval-in-repl)

This works just as I expected if I run it like M-x reload-and-eval-in-repl or I eval the expression (reload-and-eval-in-repl), but when I try to use the keybinding s-e I get the error:

Wrong type argument: commandp, reolad-and-eval-in-repl

I know that error usually means you forgot the (interactive) call, but this isn't the case, so I'm a bit lost.


texts: My imenu-entries get double listed. How could I correct that?

texts:
With the PHP-mode that's shipped with Emacs, suppose I have the following PHP function:

public function foo()
{
    print "bar";
}

Imenu will list the foo in all methods and public methods.

Other packages like Helm and Ido use the same Imenu, which causes my functions to be double listed. When I call helm-imenu that uses the imenu source, I see my functions double listed.

It gets listed in helm-imenu as All methods / foo and public methods / foo. I see the same in ido-imenu.
I would like to reduce that to only the methods get listed once, instead double. And in Emacs nearly everything is scriptable, right?

To make it more clear what I'm meaning, a screenshot:

Sometimes it makes it very confusing for me, when navigating around in the codebase.

So any suggestion how I could handle this?


texts:
I have a buffer (belonging to ein mode that got into a bad state) that throws an elisp error every time I try to kill it (using ibuffer, M-x kill-this-buffer, etc.)
Backtrace suggests that the buffer is trying to run some elisp that is failing. Is it possible to just kill that buffer without running any hooks?


texts: org-mode: create new link type for structured links to headings

texts:
After reading the org-mode manual I didn't find a way to construct structured
links referring to headings with endless depth, like:

having a file.org:

* 1
** 1
** 2
*** 1
<---link here

with the link:
[[path/to/file.org::*1:2:1]]

It should work also with link abbreviations:

#+LINK: file path/to/file.org::*%s

[[file:1:2:1]]

I was told that I need to write a custom link type to achieve this. I'm aware of the <<target>>, CUSTOM_ID and ID options but they are not good for my use case, where I have a fixed, non-changing structure with a lot of short "leaves". E.g. the Bible. It doesn't make sense to mark each verse with a CUSTOM_ID, when you already have all this information in the headings hierarchy. The raw text will become less readable without any advantage in flexibility (those verses are not going to be restructured).

I'm not that experienced in writing in elisp. Is it difficult to create such custom link type? What is the closest link type that you would recommend to take as starting point (link on code, if possible)?

P.S.:

Maybe, for a more general case, it will be a good idea to be able to also add a <<target>> at the end of the tree, like:

[[MyBook:Chapter 1:Section 5:Subsection 3:target]]

* Chapter 1
...
** Section 5
...
*** Subsection 3
...
<<target>>
...


texts: Spacemacs Python Layer Invalid version syntax: '[?1034h4.0.0'

texts:
When I attempt to start Spacemacs with the Python layer enabled, I see a warning:

Error (use-package): python :init: Invalid version syntax: '[?1034h4.0.0'

Restarting emacs using --debug-init shows:

Debugger entered--Lisp error: (error "Invalid version syntax: '[?1034h4.0.0'")
  signal(error ("Invalid version syntax: '[?1034h4.0.0'"))
  error("Invalid version syntax: '%s'" "[?1034h4.0.0")
  version-to-list("[?1034h4.0.0")
  version<("[?1034h4.0.0" "5")`

Plus a lot more.

When I comment out the python layer from dotspacemacs-configuration-layers  in the .spacemacs file, the error goes away (but, of course, no Python layer is enabled).

Any clues as to how to debug this would be appreciated.

This is running on OS X 10.12.2 With GNU Emacs 24.5.1 and Spacemacs v.0.200.7

And running (executable-find "ipython") results in /Users/xxx/anaconda/bin/ipython Same executable for python


texts: Why is `key-chord-mode` not listed among enabled minor modes?

texts:
After starting Emacs with the following init.el file, key-chord-mode is turned on.

;; Speed up startup
(setq gc-cons-threshold 402653184
      gc-cons-percentage 0.6)
(add-hook 'after-init-hook
          `(lambda ()
             (setq gc-cons-threshold 800000
                   gc-cons-percentage 0.1)
             (garbage-collect)) t)

;; Initialize package.el
(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives
             '("org" . "https://orgmode.org/elpa/") t)
(package-initialize)

;; Bootstrap `use-package'
(setq-default use-package-always-ensure t ; Auto-download package if not exists
              use-package-always-defer t ; Always defer load package to speed up startup
              use-package-verbose nil ; Don't report loading details
              use-package-expand-minimally t  ; make the expanded code as minimal as possible
              use-package-enable-imenu-support t) ; Let imenu finds use-package definitions
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(eval-when-compile
  (require 'use-package))

(use-package use-package-chords
  :ensure t
  :defer nil
  :config (key-chord-mode 1))

;;; init.el ends here

But it's not listed when I do C-h m.

So I guess my question is: in order to determine whether a certain minor mode has been enabled after starting emacs, is there something else I need to do other than C-h m?


texts: Why certain rebind keys doesn't work in c++ mode?

texts:
I've recently started using emacs and wanted to customize the editor. So, I've tried to rebind certains keys, but It's doesn't to work no matter what I do.

(global-unset-key (kbd "C-c") )
(global-set-key (kbd "C-c") 'forward-char)

In c++-mode, It keeps adding comments. Why is that? And how can I rebind the key effectively?


texts: Shift key does not fully work in Juypter Notebook's terminal

texts:
The Shift key sometimes does not seem to work in emacs, when emacs is launched in Jupyter Notebook's terminal (in non-window mode). Other meta keys such as Ctrl and Alt on a PC keyboard work as usual.

When trying to move to the end of the buffer with Shift+Alt+→, nothing happens. This is tested with Jupyter Hub on Ubuntu 18.04, and the clients are Firefox and Chrome.

However, the Shift key seems to work for selecting multiple lines.

I am not sure whether this relates to how browsers handle the Shift key, or where it went wrong.

Does any one have experience using emacs in Jupyter's terminal and know of a fix?


texts: Create table for existing data using org-mode

texts:
Is there a way of creating table for existing data using org-mode ?
Let's assume I have the following data

row1
row2
row3

And now I want to create a table of dimension 1x3 (col*row) on it.
The resulting output should be something like this:

| row1 |
|------|
| row2 |
| row3 |

Or even a variation of the above output should be ok.


texts: The logical way should be C-u D to delete selected files permanently. How can we do that?


texts: Gnus, send PGP encrypted message to address distinct from the one registered with the key?

texts: My friend has changed email account, but I only have his old key (which only lists his other email, now defunct). How can I tell Gnus to use the key I have, but to send it to a different email?


texts: How to get JSON response only from an ob-restclient block

texts:
I'm trying to construct an Org-based pipeline for some DevOps activities. Part of this requires making REST API calls and proceeding based on the results of those calls. I'm using ob-restclient for making actual requests. One example would be:
#+name: applications
#+begin_src restclient :output value raw
  GET :host/rest/deploy/application
  Authorization: Basic :auth
  Connection: keep-alive
  Accept: application/json
  Content-Type: application/json
#+end_src

:host and :auth are variables that I define elsewhere. Now, this works fine, except the RESULTS section looks like this:
#+RESULTS: applications
#+BEGIN_SRC js
[
  {
    ...
  }
  ...
]

// <some response headers>
#+END_SRC

I want to be able to use the named result (applications) as input variable to another code block, but the problem is, it's not a pure JSON string, but also contains the JS codeblock markers and the response headers. Any idea how I could get only the JSON part without parsing this string output? I suspect this might be configurable on restclient's side, but I was unable to find a solution.


texts:
Since Emacs 25.1, syntax-begin-function is obsolete:

syntax-begin-function is a variable defined in ‘syntax.el’.
Its value is nil

  This variable is obsolete since 25.1.
  This variable may be risky if used as a file-local variable.

Documentation:
Function to move back outside of any comment/string/paren.
This function should move the cursor back to some syntactically safe
point (where the PPSS is equivalent to nil).

This was done in commit dd1e6846198e559b1c2ca321a1e6f8b05945fd66 which offers no further explanation how that functionality should be achieved now.  The code also still refers to syntax-begin-function in several comments as if nothing happened.

php-mode just surrounded the offending code with with-no-warnings (cf. https://github.com/ejmr/php-mode/blob/master/php-mode.el#L1193-L1196), and other projects seem to have found no "proper" solution yet either.  The function php-mode used for this variable, c-beginning-of-syntax, refers to font-lock-beginning-of-syntax-function which was also removed in Emacs 25.1 (but, again, is referred to in several other comments as well).

If I completely remove the section:

  ;; syntax-begin-function is obsolete in Emacs 25.1
  (with-no-warnings
    (set (make-local-variable 'syntax-begin-function)
         'c-beginning-of-syntax))

from php-mode.el and test it with Emacs 24.3 and 25.2, I don't see any obvious adverse effects.

What was syntax-begin-function obsoleted in favour of?  Is the reference in php-mode.el just dead code that did nothing?  If not, how can I test its behaviour?


texts: Pre fill minibuffer upon calling to helm-projectile function

texts:
Based on this answer, and its with-initial-minibuffer function, I am trying to call helm-projectile-grep, customizing minibuffer pre-filling.

I try to avoid the default behaviour, which is to pre-fill the minibuffer with the contents of the region (if active) or the thing at point.

If I use

(defun with-initial-minibuffer-projectile-grep (str)
  (interactive)
  (funcall `(lambda ()
              (interactive)
              (minibuffer-with-setup-hook
                  (lambda () (insert (format ": %s " ,str)))
                (call-interactively 'helm-projectile-grep)))))

and then I call it with

(with-initial-minibuffer-projectile-grep "mytext")

things go wrong. Any idea of where to start from ?


texts: Global cycling one step at a time in orgmode

texts:
Building on a previous question (https://emacs.stackexchange.com/questions/58445/cycling-visibility-in-orgmode-headings[Cycling visibility in orgmode headings]1
I would like that S-TAB (or an alternative) cycles "one step" at a time: -> TOP LEVEL HEADINGS -> SECOND LEVELS -> THIRD LEVELS -> (so forth) … -> SHOW ALL
Can this be done with built in tools or does one need to program a new solution?


texts: Why is this .org file not using any org-mode highlighting?

texts:
I'm trying to highlight a syllable within a word in order to show that it is different from another word. How can I do this with * in org-mode and then properly export to LaTeX?

I'm on Windows 7 32-bit, Emacs 24.4.1 (i686-pc-mingw32), Org-mode version 8.2.10.
I have followed the instructions on this page but something went wrong with Org -- it thinks an *.org file is a LaTeX file! I therefore had to comment out those lines in my .emacs configuration file. The lines I'm talking about are these:

(setcar org-emphasis-regexp-components " \t('\"{[:alpha:]")
(setcar (nthcdr 1 org-emphasis-regexp-components) "[:alpha:]- \t.,:!?;'\")}\\")
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)

I don't know why, but they don't work with my emacs. Are they still valid? Can anyone help me out, please?
By the way I have this same question open on StackOverflow (here)

Screenshots

This is the structure of vocab.org. It has LaTeX tags at the bottom of the file so that when I export only the body as vocab.tex, it doesn't have problems recognizing vocab-main.tex as its master file. vocab-main.tex is a file containing all the font and page formatting that make the final pdf look good to the eyes.


texts: I am looking at the C code for Emacs as of Emacs 26.1, file charset.c , defun char-charset (around line 2040), and file charset.h, macro CHAR_CHARSET (around line 380). I don't understand how in the world this might work. How does this not recurse without bound if ch >= 0x80 and restriction == Qnil ??


texts: Is there command to cause emacs to rescan the buffer to determine mode?

texts:
Apologies if this has been asked before (I couldn't find an answer to this.)
Frequently, when I open an existing file or create a new file with emacs, the mode is determined correctly based on the file extension (text following the last "." in the file name).  However, this doesn't work when I create a script that has a "shebang" ("#!") on the first line.  For example,
#!/usr/bin/env python

Emacs doesn't put the buffer into python mode unless I save the file (save-file) and open it again (find-file).  Is there a way to rescan the buffer to determine the mode without saving the file?
Another scenario where this would come in handy is when the buffer has:
; -*- <MODE> -*-

on the first line.


texts: link to a given page of an epub file from org mode

texts:
Is it possible to make a link from org mode to a given page or section of an epub file (epub warp) ?

I know that with "pdfview:./filename.pdf::6" we can have access to the page 6 of the pdf file.
So I tried "file:filename.epub": it opens the epub file in another buffer. But it opens it at the index section.
How to specify the page/section to open?
I tried something like "file:filename.epub::num_in_the_epub_file.xhtml#ch3" or several variations around that but it does not work.

I also tried
M-x org-store-link / M-x org-insert-link
but it seems that it does not work with epub file...

Any ideas? Thanks by advance


texts: How to handle end of file during parsing errors while reading a string?

texts:
I was trying to read and eval Lisp forms from a string using a loop, instead of just putting the string into a buffer and using eval-buffer to load everything in the string. That method was mentioned in another thread here.

The problem is that read-from-string signals an error "End of file reached during parsing" and aborts my loop. I was hoping it would return nil, or some indication of the number of characters left, or give me some other way to figure out when to end my loop.

    (while (< pos (length contents))
      (setq pair (read-from-string contents pos))
      (setq obj (car pair))
      (setq pos (cdr pair))
      .. inspect the read obj here
      .. maybe eval it, or toss it, or fix it..
      )

Read-from-string returns starting position for the next read operation in the cdr of the pair returned. So I'm thinking that's so I can use it to start the next read in the right place. But I can't find any examples of how to read a string without getting the EOF error.

Probably it's just that I don't know how handle EOF errors while reading strings. Is there an ideomatic way of handling this kind of situation? Maybe with an unwind-protect or something?


texts: How can I skip Helm/IDO when I want to open Dired?

texts:
When I call Dired with M-x Dired, I got the IDO window with the file structure and when I press Enter, he goes to Dired.

When I disable IDO in Emacs, and I do M-x Dired again, I got the Helm-dired-mode. When I confirm the current directory path, the Dired open anyways.

Is there a way to skip IDO/Helm directly when I want to open Dired?


texts:
Lets suppose I would like to edit my text and to add comments to the column in the text. This is my text:

something-text1  foobar1 something-text1
something-text2  foobar2 something-text2
---
something-textn  foobarn something-textn

I want to add comments just after the words foobar. I do the following: (|| is cursor):

||foobar1

M-x kmacro-start-macro-or-insert-counter M-x forward-word

;; comment

M-x backward-word M-x next-line M-x kmacro-end-or-call-macro

Now I can repeat this keyboard macro on every line with the word foobar with
M-x kmacro-start-macro-or-insert-counter or
C-u  kmacro-start-macro-or-insert-counter and apply the command  times.

I would like to do the same with rectangle-mark. I would like to make
region with C-x SPC C-u  С-n:

something-text1  ||foobar1 something-text1
something-text2  ||foobar2 something-text2
---
something-textn  ||foobarn something-textn

Then I eval M-x kmacro-end-or-call-macro, but it doesn't work in the way it works with help of above-mentioned command.

How can I apply a keyboard macro to every line that starts with rectangle mark region?


texts: Disable minor mode in specific major-modes or changing buffers (i.e. selectrum for prog-modes but not in shell)

texts:
This is similar to many other questions but nothing is leaping out..
I'm a fan of selectrum (similar to helm and ido I gather):
e.g. hit M-x and start typing, it'll find matches and list them.
I'd like selectrum-mode enabled during all modes (at least prog-modes), but not during a shell (M-x shell); I'm fine with a specific list of modes to disable it (i.e. enable for all, then disable selectively) or enable for specific modes, i.e. it's handy during non-prog to find-file for opening, but when in shell I want regular shell (bash/etc) based tab completion to occur.
Simple enable of selectrum is:
(selectrum-mode +1)

But this is global in all modes, all the time, so the simpler tab-completion goes instead to selectrum.
I tried putting it in an add-hook:
(add-hook 'prog-mode-hook 'selectrum-mode)

but this just enables it globally when first entering a prog-mode, I think; its not limited to prog modes. And really, I'd like it on all the time, barring some modes. The question is can selectrum be non-global at all, and even if it's a global-only minor mode, can it be toggled on and off automagically?
Without changing selectrum-mode's code to be non-global (if that's possible), I wonder if there's a way to enable/disable it selectively per mode.
What is best practice?
If it's global, could it be toggled on and off when toggling buffers? Perhaps a code fragment to hook switching buffers and disable as appropriate; i.e. on switch buffer, check if entering the list of modes, and then check if selectrum-mode is on, and then (selectrum-mode -1) if needed. This seems cumbersome and likely there is a more elegant approach.
Your help is appreciated; always love to learn something!
edit: Noticed there is a hook buffer-list-update-hook which might be usable, so perhaps I'll learn enough elisp to build the if-mode-active disable code, but I'm sure there's a much more elegant solution.


texts: How to create humanly readable delta between two times?

texts:
Given two times (in the format returned by (current-time)), does Emacs have a way to convert this to a humanly readable delta?
Examples could include:

3 days.
2 weeks, 3 days.
3 hours, 2 minutes.
tomorrow (possible alternative to 1 day)
yesterday (possible alternative to -1 day)

... etc.


texts:
I have a hash-table (named ztree-line-to-node-table) that stores the line-number and the corresponding absolute-file-name.  The absolute-file-name is extracted using (gethash line ztree-line-to-node-table).

Q:   How, please, can I extract the line-number if I know what the absolute-file-name is?

#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8 data
      (1
       #("/Users/HOME/.0.data/.0.emacs/Emacs_10_01_2014.app" 0 49
     (face ztree-start-node-face))
       2 "/Users/HOME/.0.data/.0.emacs/Emacs_10_01_2014.app/Contents" 3 "/Users/HOME/.0.data/.0.emacs/Emacs_10_01_2014.app/Contents/MacOS" 4 "/Users/HOME/.0.data/.0.emacs/Emacs_10_01_2014.app/Contents/Resources" 5 "/Users/HOME/.0.data/.0.emacs/Emacs_10_01_2014.app/Contents/Info.plist" 6 "/Users/HOME/.0.data/.0.emacs/Emacs_10_01_2014.app/Contents/PkgInfo"))

EXAMPLE:

The absolute-file-name is a path:

"/Users/HOME/.0.data/.0.emacs/Emacs_10_01_2014.app/Contents"

The line-number is 2.

I am looking for a means of programmatically querying the hash-table using the absolute-file-name to extract the line-number -- the result of the query in this example is 2.


texts: How to remove "see" from info links / cross-references?

texts:
I'm generating Django documentation to more easily reference it in Emacs. The obvious approach[^] results in cross-references having "see" prepended to them. E.g., the online documentation for Model instances says:

  This document describes the details of the Model API. It builds on the material presented in the model and database query guides, so you’ll probably want to read and understand those documents before reading this one.

whereas opening the texinfo in Info results in:

  This document describes the details of the ‘Model’ API. It builds on the
  material presented in the see model and see database query.
  guides, so you’ll probably want to read and understand those documents
  before reading this one.

How can I get rid of this "see"?

[^]: The obvious approach being:

git clone https://github.com/django/django.git
cd django && git checkout stable/1.11.x
cd docs && make texinfo
cd _build/texinfo && sudo make install-info


texts: Should I have removed `(shell . t)` to clear an ob-shell initialization error?

texts:
First post. I'd like to confirmation whether I sucessfully troubleshooted an install of Emacs, and, if I didn't, direction on where and how to proceed.

My setup:

Emacs 24.5
Macbook Pro Core Duo (mid-2010)
OSX El Cap (10.11.4)

I recently installed Emacs along with Kierian Healy's [https://kieranhealy.org/resources/emacs-starter-kit/](social science starter kit). When I first launched Emacs after the installation I received an error (below) that as far as I could tell, didn't prevent anything from working—although, given that I'm new to Emacs one can never be sure.

Once installed, I received the follwing error message at launch:

Warning (initialization): An error occurred while loading
`/Users/lmp/.emacs.d/init.el':

File error: Cannot open load file, no such file or directory, ob-shell

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.

I launched Emacs from the terminal into debug mode but couldn't for the life of me figure out the backtrace. So I commented out sections of my init.el file until I found the problem line of code:

(org-babel-load-file (expand-file-name "starter-kit.org" dotfiles-dir))

So I opened the starter-kit.org file and do the same which leads me to the following code

(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(shell . t)))

After searching the org-mode website and a few forums, I tried the following that cleared the error:

(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)))

It's my understanding that the . t part of the code is a true/false signifier. But whether removing it from the file was wise or foolish, is what I want to know. Or, to state my question in the clearest of terms:

Did I successfully fix the problem? If not, why not?
Is there anything I should have done instead, or should do in addition to removing the (shell . t)?


texts: How do you remove the last few characters from all lines in a txt file in spacemacs?

texts:
How do you remove the last few characters from all lines in a text file?

Example:

23193 123252 1
1238 123 1
34356363 11238080123 1

Should become:

23193 123252
1238 123
34356363 11238080123

I'm using the evil interface in Spacemacs.


texts: How to send keyboard interrupt to running program in shell mode?

texts: I wish to achieve what a C-c (send a keyboardinterrupt) would do in a terminal outside of Emacs. How do I do that in Emacs shell mode?


texts:
When I try to connect to a remote machine from an ansi-term terminal using mosh (a remote terminal application), I get the following:

$ mosh -- user@host.domain

mosh-server needs a UTF-8 native locale to run.

Unfortunately, the local environment (LC_CTYPE=) specifies
the character set "US-ASCII",

The client-supplied environment (LC_CTYPE=) specifies
the character set "US-ASCII".

LANG=
LC_CTYPE=
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
Connection to user@host.domain closed.
/usr/local/bin/mosh: Did not find mosh server startup message.

I don't have this problem from iTerm2.


texts: Launch EXWM only when no another WM or DE are being used

texts:
I use EXWM sometimes, but while i do appreciate it, i found myself using other WM and DE (either because i use my emacs config on another computer, since the config is in a usb stick, or other off-topic reasons) but because of the way i use it, which is the following:

 (use-package exwm
    :ensure t
    :config

      ;; necessary to configure exwm manually
      (require 'exwm-config)

      ;; fringe size, most people prefer 1
      (fringe-mode 3)

      ;; emacs as a daemon, use "emacsclient <filename>" to seamlessly edit files from the terminal directly in the exwm instance
      (server-start)

      ;; this fixes issues with ido mode, if you use helm, get rid of it
      (exwm-config-ido)

      ;; a number between 1 and 9, exwm creates workspaces dynamically so I like starting out with 1
      (setq exwm-workspace-number 1)

      ;; this is a way to declare truly global/always working keybindings
      ;; this is a nifty way to go back from char mode to line mode without using the mouse
      (exwm-input-set-key (kbd "s-r") #'exwm-reset)
      (exwm-input-set-key (kbd "s-k") #'exwm-workspace-delete)
      (exwm-input-set-key (kbd "s-w") #'exwm-workspace-swap)

      ;; the next loop will bind s-<number> to switch to the corresponding workspace
      (dotimes (i 10)
        (exwm-input-set-key (kbd (format "s-%d" i))
                            `(lambda ()
                               (interactive)
                               (exwm-workspace-switch-create ,i))))

      ;; the simplest launcher, I keep it in only if dmenu eventually stopped working or something
      (exwm-input-set-key (kbd "s-&")
                          (lambda (command)
                            (interactive (list (read-shell-command "$ ")))
                            (start-process-shell-command command nil command)))

      ;; an easy way to make keybindings work *only* in line mode
      (push ?\C-q exwm-input-prefix-keys)
      (define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key)

      ;; simulation keys are keys that exwm will send to the exwm buffer upon inputting a key combination
      (exwm-input-set-simulation-keys
       '(
         ;; movement
         ([?\C-b] . left)
         ([?\M-b] . C-left)
         ([?\C-f] . right)
         ([?\M-f] . C-right)
         ([?\C-p] . up)
         ([?\C-n] . down)
         ([?\C-a] . home)
         ([?\C-e] . end)
         ([?\M-v] . prior)
         ([?\C-v] . next)
         ([?\C-d] . delete)
         ([?\C-k] . (S-end delete))
         ;; cut/paste
         ([?\C-w] . ?\C-x)
         ([?\M-w] . ?\C-c)
         ([?\C-y] . ?\C-v)
         ;; search
         ([?\C-s] . ?\C-f)))

      ;; this little bit will make sure that XF86 keys work in exwm buffers as well
      (dolist (k '(XF86AudioLowerVolume
                 XF86AudioRaiseVolume
                 XF86PowerOff
                 XF86AudioMute
                 XF86AudioPlay
                 XF86AudioStop
                 XF86AudioPrev
                 XF86AudioNext
                 XF86ScreenSaver
                 XF68Back
                 XF86Forward
                 Scroll_Lock
                 print))
      (cl-pushnew k exwm-input-prefix-keys))

      ;; this just enables exwm, it started automatically once everything is ready
      (exwm-enable))

I come to want to be able to start EXWM (as emacs start) only if no other DE or WM are in use. How could i make that work with my current config?


texts:
Most magit commands are invoked with a single key, which pops up a menu of
subcommands and switches.  For example, P shows P and t as subcommands and -f and -u as "switches."

Hitting the letters for the subcommands invokes them, but how does one invoke
the switches?  I have a repository with two remotes, and I wanted to push to
the other remote.  The -u switch looks like just the thing, but if I type P -u, the -u turns red, but Magit does not prompt for the remote.

The manual says nothing about these switches for any of the commands as far as
I can tell.

Could someone explain how these switches are used in general.  I'm not just
concerned with this particular switch, but with the facility in general.


texts: How to support multiple extensions in Deft?

texts:
In deft mode I can change the default text extension using

(setq deft-extension "txt")

Is there any way to support multiple file types? (e.g. I have a mix of .txt .md and .org files in my directory)


texts: How to activate diff-mode from command line?

texts:
Git's editor config is set to launch emacs in no-window mode and to execute lisp function diff-mode:

git config --global core.editor "emacs -nw -f diff-mode"

However, when I execute git commit -v to edit a commit message (the -v flag provides the diff to the editor), diff-mode is not activated:

Manually activating the mode by executing the function (Mod+X diff-mode) does work at this point:

Why does the mode not get activated when I supply -f diff-mode on the command line?


texts: Can I use a dynamic parameter for a org clocktable's "block" in BEGIN?

texts:
I am generating monthly bills with org-mode which also includes a clocktable. The month ideally should be only defined once at the top of the file and the value then be used by any dynamic block.

Can I reference a variable like #+Date: 2019-03 or the result of a src block from within the definition of my clocktable?

pseudo code:

#+NAME: get_block
#+BEGIN_SRC python
return "2019-03"
#+END_SRC

#+BEGIN: clocktable :block (get_block) ...

I saw something similar for :scope but would want something embedded in the file: https://emacs.stackexchange.com/a/7903/21642


texts: tramp: $INSIDE_EMACS isn't defined while .bashrc is processed

texts:
It seems INSIDE_EMACS can be used to determine if tramp is used. I know I could use test "$TERM" = "dumb" but if [[ -z $INSIDE_EMACS ]]; then is provided by the home-manager tool.

If I set tramp-verbose I can see that INSIDE_EMACS is defined in some tramp sessions but it's not when my .bashrc is processed. I wonder if INSIDE_EMACS could be set after the shell starts.

Any ideas?

GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.14, cairo version 1.16.0)

  Determining a TRAMP session

Sometimes, it is needed to identify whether a shell runs under TRAMP control. The setting of environment variable TERM will help:

if test "$TERM" = "dumb"; then
   ...
fi

Another possibility is to check the environment variable INSIDE_EMACS. Like for all subprocesses of Emacs, this is set to the

  version of the parent Emacs process, See (emacs)Interactive Shell.
  TRAMP adds its own package version to this string, which could be used
  for further tests in an inferior shell. The string of that environment
  variable looks always like

echo $INSIDE_EMACS
⇒ 26.2,tramp:2.3.4

https://www.gnu.org/software/tramp/

.bashrc

if [[ -z $INSIDE_EMACS ]]; then
  eval "$(/nix/store/ni6mmldfii7mljhnism2rn0pwchr2fmz-starship-0.40.1/bin/starship init bash)"
fi


texts:
I am opening a Java source file which is part of a maven project. JDEE now runs maven once, which I can sort of understand. But whenever I move around in the file, it will trigger once more. Since it always splits my frame, and blocks Emacs, this is quite annoying.

Is there a how to or some rules on how to set up Emacs and JDEE for my Maven projects, so that this will not happen?


texts:
When semantic-stickyfunc-mode is activated, the tabbar tabs are not visible.

I would like to write a function that show the tabs 2 seconds and then goes to semantic-stickyfunc-mode.

I tried with this:

     (defun timer-local-tabbar-show()
        (if (eq major-mode 'python-mode)
            (progn
              (tabbar-local-mode -1)
              (run-with-timer 2 nil (lambda () (tabbar-local-mode 1))))))
      (add-hook 'window-configuration-change-hook 'timer-local-tabbar-show)

The tabs are shown, and then disappear (good ;-), but semantic-stickyFunc-mode doesn't work (while semantic-stickyFunc-mode variable is 1)

Thank you for any help.

EDIT:

(defvar my-header-line-format nil)
  (defun timer-local-tabbar-show()
    (if (eq major-mode 'python-mode)
        (progn
          (setq my-header-line-format header-line-format)
          (tabbar-local-mode -1)
          (run-with-timer 1.5 nil
                          (lambda ()
                            (tabbar-local-mode 1)
                            (setq header-line-format my-header-line-format)
                            (redisplay)
                            )))))
  (add-hook 'window-configuration-change-hook 'timer-local-tabbar-show)

This version works better (thanks lawlist) but there are somme persistent random problems.


texts: Yasnippet: How to automatically advance to next field after `yas-choose-value`

texts:
Yasnippet has a function called yas-choose-value which is used like this:

<div align="${2:$$(yas-choose-value '("right" "center" "left"))}">
  $0
</div>

How can I automatically exit the snippet and move to $0 after pressing the return key when making the selection from the choices?


texts: Why does Flycheck complain "mapcar called for effect" when my function returns the result of mapcar by design?

texts:
Since installing Flycheck I've been bombarded with complaints about the elisp functions I've used reliably for years.  This is the first one I can't understand.  Here my function is designed to return the result of mapcar, not to produce side effects.  The suggested replacement of mapc won't do what I need, though dolist could with a bit more effort.

Here's the code:

(defun synclient-get-touchpad-config ()
  "Return the touchpad config as a list of strings."
  (mapcar (lambda (s)
            (string-join (split-string s)))
          (seq-drop-while (lambda (s)
                            (not (string-prefix-p " " s)))
                          (process-lines "synclient" "-l")))
  (current-buffer))

The exact error message is:

‘mapcar’ called for effect; use ‘mapc’ or ‘dolist’ instead (emacs-lisp)

What exactly is flycheck expecting me to do here?


texts:
Assuming I have a task where I store a timestamp for every taskchange I do:

* DONE Extremely important dummy task         :categorywhatevs:
- State "DONE"       from "IN PROGRESS" [2015-06-08 Mo 14:19]
- State "In PROGRESS"       from "URGENT"     [2015-06-04 Do 08:36]
- State "URGENT"     from "QUEUE"      [2015-06-04 Do 08:09]
- State "QUEUE"      from ""           [2015-06-04 Do 08:09]

These timestamps contain valuable information: Theoretically I can deduce how long a distinct task took me. We even can think about an outlook and have an analysis which measures the average task duration - certainly good for planning ahead.

But here I have a problem: How do I get this information? Of course I could string-parse everything under the task and store the durations within some property tags. I could do this automatically by using a hook (the org-after-todo-state-change-hook seems to be a good candidate). However as a complete lisp newbie I do not know how I got the information in upper two lines below a heading.


texts: How to maximize my Emacs frame on start-up?

texts:
Is there a way to maximize my window on start-up?

Currently, I hit Control++Up on my keyboard but it is very bothersome to do that every time.

I am using Emacs 24.4 on Ubuntu 12.04.


texts: helm-bibtex and Zotero with better-bibtex -- Cannot find PDF

texts:
Using org-ref and helm-bibtex I can insert a reference into my org file that will be displayed as a link in the shape of cite:kaufmann_eigensolver_2007. I can hit RET and get a menu from helm-bibtex with common actions on that citation.

The goal

What I'd like is to be able to directly open the PDF given in the file field of the bibtex entry (supplied by Zotero).

The problem

When picking "Open PDF" in the helm-bibtex menu I get the message "no pdf found for <key>"

My configuration

I have set up better-bibtex to export by Zotero library to a bib file. The entries look like this:

@incollection{kaufmann_eigensolver_2007,
  title = {Eigensolver {{Methods}} for {{Progressive Multidimensional Scaling}} of {{Large Data}}},
  ...,
  file = {C\:\\Users\\Ben\\Zotero\\storage\\Q2YBABVH\\Brandes and Pich - 2007 - Eigensolver Methods for Progressive Multidimension.pdf},
  ...
}

My config looks like this

  ;; configure bibtex layer
  (setq org-ref-default-bibliography '("/Users/Ben/Dropbox/Library.bib")
        org-ref-bibliography-notes "/Users/Ben/Dropbox/org/org-ref-notes.org")

  (setq bibtex-completion-bibliograph "/Users/Ben/Dropbox/Library.bib")
  (setq bibtex-completion-pdf-field "file")
  (setq bibtex-completion-pdf-open-function
        (lambda (fpath)
          (debug)
          (start-process "open" "*open*" "open" fpath)))

What I've tried

Changing the PDF file name to accomodate the bibtex key (kaufmann_eigensolver_2007.pdf)
Manually editing the file field and try different variations of double/single/forward/backward slashes
Some basic debugging but I have to say im pretty lust on how to use debug in emacs.
Looking at the source code of the relevant function of helm-bibtex but I cant really make sense of it.


texts: How can I set Emacs up for iOS development with Swift?

texts:
I'm going to be doing a bit of iOS work soon, using Swift (yay!). Unfortunately, this usually involves xcode (boo!).

How can I set Emacs up to build iOS apps with Swift? Ideally, they would run on my testing device automatically. More advanced functionality like autocomplete would be nice too, but not critical.


texts: Auto generated code in the init file when updating packages

texts:
Every time I use the package manager it puts auto generated code in the init.el file:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ansi-color-faces-vector
   [default default default italic underline success warning error])
 ...
 )

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(fringe ((t (:background "grey10"))))
 ...
 )

This doesn't seem to be doing anything critical and only messes up my interface and theme colors.

Is there a way to stop Custom generated code?

Or at least this specific code (I'm assuming it's coming from the packages I have installed).


texts: How to disable Flycheck when editing in sudo?

texts:
Sometimes I want to edit a file in Emacs as root. So I found this useful function:

(defun sudo-edit (&optional arg)
  "Edit currently visited file as root.
With a prefix ARG prompt for a file to visit.
Will also prompt for a file to visit if current
buffer is not visiting a file."
       (interactive "P")
       (if (or arg (not buffer-file-name))
           (find-file (concat "/sudo:root@localhost:"
                              (ido-read-file-name "Find file(as root): ")))
         (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))

But I'm not able to save the file, I got the following error message:

  Suspicious state from syntax checker emacs-lisp: Flycheck checker
  emacs-lisp returned non-zero exit code 255, but its output contained
  no errors: Opening input file: No such file or directory,
  /sudo:root@localhost:/etc/mysql/flycheck_my.cnf

This problem is understandable. In order to get flycheck-package (an alternative to Flymake) working, it tries to create the file flycheck_my.cnf in directory mysql, but it don't have any write access in order to create the file.

So I modified the function as following:

(defun sudo-edit (&optional arg)
  "Edit currently visited file as root.

With a prefix ARG prompt for a file to visit.
Will also prompt for a file to visit if current
buffer is not visiting a file."
       (interactive "P")
       (if (or arg (not buffer-file-name))
           (find-file (concat "/sudo:root@localhost:"
                              (ido-read-file-name "Find file(as root): ")
                              (flycheck-mode nil)
                              ))
         (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))
         (flycheck-mode nil)
         ))

But I keep the same error message, while the flycheck-mode is disabled. So somewhere I went wrong. But where? And why?


texts: Org-mode: any keyboard shortcut for Latex code?

texts:
On p.33 of the Org-guide Carsten Dominek writes

  you can use #+LATEX: and #+BEGIN_LATEX ... #+END_LATEX construct to add verbatim LATEX code

Is there a keyboard combination or default snippet that automatically types either of those constructs into the .org file in a similar fashion to <s followed by TAB that adds #+BEGIN_SRC? (see minute 3:00 in this youtube tutorial)


texts: In many other softwares (e.g., Chrome), when we initiate word search by Ctrl-F, the pre-input is pre-selected so that we can replace it by simply typing a new keyword, or append a new string to it by first pressing right-arrow key. Could we have the same behavior in helm (e.g., helm-swoop)?


texts: In exwm (Emacs X Window Manager) how can I switch to previous workspace?

texts: Say I'm in workspace 1 and I switch to workspace 3. Currently I have to remember that I was in workspace 1 but I want some sort of functionality to to do this for me. In i3wm I can enable workspace_auto_back_and_forth to achieve this. I there anyway to have the same thing in exwm?


texts:
I inherited my .emacs file from a friend about 18 years ago.  Buried in the middle is the following ominous comment warning about the security implications of the enable-local-variables feature:

;; Date: Wed, 7 Dec 1994 11:57:50 -0600
;; From: blob@syl.dl.nec.com (David Blob)
;; Subject: Self-extracting emacs elisp code
;;
;; With all this talk about self extracting mail "viruses", a friend
;; showed me that in emacs (which I use to read mail, along with vm)
;; has the ability to self-extract elisp code. This feature seems to
;; be turned on by default, and it not only applies to mail read with
;; emacs, but rather every file visited (when the feature is on, of
;; course).
;;
;; The way it works is by having a line which reads "Local Variables:"
;; followed by the lisp variables you would like to set...well, it may
;; seem petty, but you can execute programs, make connections and much
;; more through cleverly written elisp code contained within.
;;
;; It's simple to turn off, at any rate...
;;
;; (setq enable-local-variables  f) ;; turns off feature  (in emacs 19)
;; (setq enable-local-variables  1) ;; makes it ask first (in emacs 19)
;; (setq inhibit-local-variables t) ;; turns off feature  (in emacs 18)
;;
;; Anyhow, I think the risks here speak for themselves...
;;
(setq enable-local-variables '())

So I've never actually used the local-variables feature even though it seems like it could be pretty useful.  Is there a way to enable-local-variables that does something useful without exposing me to arbitrary code-injection attacks?


texts: How to move by defun without moving up a level?

texts:
I am attempting to navigate methods in a file. Typically these are javascript or python files, which have a classes at the "top level", which in turn have methods nested within those definitions.
When I try to navigate by defun (end-of-defun or beginning-of-defun) the cursor will often end up at the next or previous class definition, not the next or previous method.
Is this the intended behaviour? How can I navigate by the methods?


texts:
Does emacs/elisp have something equivalent or similar to Clojure's datomic?

What I tried: google emacs datomic

fyi by datomic I'm referring to this: https://en.wikipedia.org/wiki/Datomic


texts: Run a function before/after magit runs git

texts: I'd like to run a function before magit runs git, and another one after magit runs git. I see magit-pre-start-git-hook but I don't see any post-finish-git hook. How can I run commands before and after magit runs git?


texts: In M-x Info (C-h i), tables are not correctly aligned

texts:
Problem

When trying to browse documentation in M-x info ≡ C-h i, the table of contents is not correctly aligned. One would expect

* Introduction     This is the etc etc etc etc etc .
* Details          Bla bla bla bla bla bla bla
                     bla bla bla bla bla.
* More             Yada yada yada yada.

but gets

* Introduction This is the etc etc etc etc etc .
* Details Bla bla bla bla bla bla bla
bla bla bla bla bla.
* More Yada yada yada yada.

Solution

Check the value of C-h v font-lock-extra-managed-props, see detailed answer below.


texts:
Powerline shows git branch information for a buffer that are under version control vc-mode. Only when vc-mode is set for a buffer the Git branch information is displayed. When inside dired there is no Version Control information shown. Is there a way to enable vc-mode for dired so that at least the branch information is shown without needing to patch powerline.el ?

To visualize what I mean: This is the powerline for buffers that have vc-mode set:

The powerline for the dired buffer has no vc-mode set and the branch information is missing:


texts:
I am trying to move from Sublime to Emacs. (Because free and all that.) One thing that I miss is the convenient text expansion available by default in Sublime where it picks up similar strings in the same buffer and makes it easy to select a proper expansion. I am sure this is possible in emacs also but haven't figured out how yet.

When I start typing on a string that is already present in the buffer I would like to be able to expand using a shortcut like Ctrl-Space, Alt-Enter or something like that. How do I set this up?

Bonus question. How to find expansion candidates in other buffers also as a secondary option?

UPDATE: tried out dabbrev and it seems to be what sublime does. I sense that the step to move on towards more dynamic completions isn't that far away but I will leave it for now. I bound M-RET to M-/ with:

(global-set-key (kbd "M-RET") 'dabbrev-expand)

(Why I don't like M-/? Because on a swedish keyboard it comes with a Shift. / is Shift-7.....)


texts: Am new to Emacs and am using Spacemacs, Emacs mode. After following the basic Emacs tutorial, I create an html file and try to use emacs for code editing. So I installed the html layer, after activating emmet-mode, it still stuck at web-mode. And I got any autocompletion. Like typing :.my-class + TAB don't generate any code.


texts: Org agenda - toggle TODO state backwards?

texts:
In org agenda mode, pressing t advances the TODO state of the item one step forward (to the next TODO keyword in order).

How can I add a binding to move the TODO state backwards by one step? I have a setup with several states, and advancing one step too far is very annoying as I have to toggle all states until I restore the previous state.


texts: Custom made rgrep via ack stopped working

texts:
I used to use the function below to call ack as a fast, recursive grep, but for whatever reason it stopped working. More precisely it returns no result. It probably happened when I updated Emacs or macOS, hard to say.
The ack is working from terminal without any issues.
Does anyone have any idea how to fix it? I also considering alternatives, but hopefully not too slow for big folders.
(defun my/rgrep ()
  (interactive)
  (if (executable-find "ack")
    (let* ((regexp (grep-read-regexp))
            (dir (read-directory-name "Base directory: " nil default-directory t))
            (command (concat "ack '" regexp "' " dir)))
      (unless (file-accessible-directory-p dir)
        (error (concat "directory: '" dir "' is not accessible.")))
        (compilation-start command 'grep-mode))
    ))

EDIT:
Sadly even rgrep doesn't work when evaluated as (progn (grep-compute-defaults) (rgrep "foo" "*.txt" "/Volumes/RAM_Disk/test")) where that folder has only one txt file with text "foo" it returns no matches. The generated find command below:
find . -type d \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS -o -path \*/MCVS -o -path \*/.src -o -path \*/.svn -o -path \*/.git -o -path \*/.hg -o -path \*/.bzr -o -path \*/_MTN -o -path \*/_darcs -o -path \*/\{arch\} \) -prune -o \! -type d \( -name .\#\* -o -name \*.o -o -name \*\~ -o -name \*.bin -o -name \*.lbin -o -name \*.so -o -name \*.a -o -name \*.ln -o -name \*.blg -o -name \*.bbl -o -name \*.elc -o -name \*.lof -o -name \*.glo -o -name \*.idx -o -name \*.lot -o -name \*.fmt -o -name \*.tfm -o -name \*.class -o -name \*.fas -o -name \*.lib -o -name \*.mem -o -name \*.x86f -o -name \*.sparcf -o -name \*.dfsl -o -name \*.pfsl -o -name \*.d64fsl -o -name \*.p64fsl -o -name \*.lx64fsl -o -name \*.lx32fsl -o -name \*.dx64fsl -o -name \*.dx32fsl -o -name \*.fx64fsl -o -name \*.fx32fsl -o -name \*.sx64fsl -o -name \*.sx32fsl -o -name \*.wx64fsl -o -name \*.wx32fsl -o -name \*.fasl -o -name \*.ufsl -o -name \*.fsl -o -name \*.dxl -o -name \*.lo -o -name \*.la -o -name \*.gmo -o -name \*.mo -o -name \*.toc -o -name \*.aux -o -name \*.cp -o -name \*.fn -o -name \*.ky -o -name \*.pg -o -name \*.tp -o -name \*.vr -o -name \*.cps -o -name \*.fns -o -name \*.kys -o -name \*.pgs -o -name \*.tps -o -name \*.vrs -o -name \*.pyc -o -name \*.pyo \) -prune -o  -type f \( -iregex \*.txt \) -exec grep -i -nH --null -e foo \{\} +

After more pondering on this, I found that there is also a problem with running rgrep or any alternative in tramp.
I think of making a universal my/rgrep function that will use default strategy like ack, and fallback to another strategy like ag and find/grep if the previous one wasn't found. Also making it work with tramp.
Because I already have defined config for ack that works well from the terminal I would put ack on the front of that list, but it shouldn't matter which one we put first.
Does anyone of you have this problem solved already, or at least have configured tramp to work well with rgrep?


texts: Is it possible to highlight the region uniformly across different sizes/fonts?

texts:
Highlighting the region when it includes text with different heights/fonts shows gaps and different highlighting heights as follows:

Is there any way of highlighting continuously (no gaps) and consistently (same height)?


texts: Is there any way to run a hook function only once?

texts:
The context

I'm using the after-make-frame-functions hook to load properly the themes in an emacs client/server configuration. Specifically this is the code snippet that I use to make that (based in this SO answer):

 (if (daemonp)
      (add-hook 'after-make-frame-functions
          (lambda (frame)
              (select-frame frame)
              (load-theme 'monokai t)
              ;; setup the smart-mode-line and its theme
              (sml/setup)))
      (progn (load-theme 'monokai t)
             (sml/setup)))

The problem

When a new emacsclient -c/t session is started the hook is executed not only in the new frame, but in all the previous existent frames (other emacsclient sessions) and it makes a very annoying visual effect (the themes are loaded again in all those frames). Even worse, in the terminal clients already opened the theme color get completely messed up. Obviously that happens only on the emacs clients connected to the same emacs server. The reason for this behavior is clear, the hook is run on the server and all of its clients are affected.

The question

Is there any way to execute this function only once or getting the same result without using the hook?

A partial solution

I have now this code, thanks to the @Drew's answer. But still has a problem, once you start a client session in the terminal, the GUI does not load the themes properly and vice-versa. After a lot of tests, I realized that the behavior depends on which emacsclient starts first, and after discard various things, I think that it is maybe related with the color palette that is loaded. If you reload manually the theme all works fine and that's the reason why this behavior does not appear when the function is called by the hook every time as in my initial configuration.

(defun emacsclient-setup-theme-function (frame)
  (progn
    (select-frame frame)
    (load-theme 'monokai t)
    ;; setup the smart-mode-line and its theme
    (sml/setup)
    (remove-hook 'after-make-frame-functions 'emacsclient-setup-theme-function)))

(if (daemonp)
    (add-hook 'after-make-frame-functions 'emacsclient-setup-theme-function)
    (progn (load-theme 'monokai t)
           (sml/setup)))

The final solution

Finally I have totally working code that solves the behavior seen in the partial solution, to achieve this I run the function once by mode (terminal or gui) when then pertinent emacsclient is started for first time, then remove the function from the hook because is no needed any more. Now, I am happy! :)
Thanks again @Drew!

The code:

(setq myGraphicModeHash (make-hash-table :test 'equal :size 2))
(puthash "gui" t myGraphicModeHash)
(puthash "term" t myGraphicModeHash)

(defun emacsclient-setup-theme-function (frame)
  (let ((gui (gethash "gui" myGraphicModeHash))
        (ter (gethash "term" myGraphicModeHash)))
    (progn
      (select-frame frame)
      (when (or gui ter)
        (progn
          (load-theme 'monokai t)
          ;; setup the smart-mode-line and its theme
          (sml/setup)
          (sml/apply-theme 'dark)
          (if (display-graphic-p)
              (puthash "gui" nil myGraphicModeHash)
            (puthash "term" nil myGraphicModeHash))))
      (when (not (and gui ter))
        (remove-hook 'after-make-frame-functions 'emacsclient-setup-theme-function)))))

(if (daemonp)
    (add-hook 'after-make-frame-functions 'emacsclient-setup-theme-function)
  (progn (load-theme 'monokai t)
         (sml/setup)))


texts: Cannot evaluate matplotlib in Python code block

texts:
These are my first attempts to plot graph in Python.
Following this example , I tried a very simple graph
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np

x = np.linspace(0, 20, 100)
plt.plot(x, np.sin(x))
plt.show()
plt.savefig('python-matplot-fig.png')
return 'python-matplot-fig.png' # return filename to org-mode

I got an error :
Traceback (most recent call last):
  File "<stdin>", line 13, in <module>
  File "<stdin>", line 3, in main
ImportError: No module named matplotlib.pyplot

Whereas I have the python installed and running on my system.
On VsCode, it is calculated

I use spacemacs python layer
  dotspacemacs-configuration-layers
   '(
     (python
      :variables
      python-backend 'anaconda
      python-format-on-save t
      python-sort-imports-on-save t)


texts: Multiple Scheduled Timestamps for One Task

texts:
Suppose I want to be reminded to water my plants on Monday, Wednesday, and Friday, AND on any of the following days, if for some reason I miss the scheduled days.

I originally tried the following:

*** water plants (1,3,5)
    SCHEDULED: <2016-08-29 Mon ++1w><2016-08-31 Wed ++1w><2016-08-26 Fri ++1w>

This does not work -- only the first timestamp is scheduled. The other two are treated as regular timestamps.

I also tried the following, and it does not work:

*** water plants (1,3,5)
    SCHEDULED: <2016-08-29 Mon ++1w>
    SCHEDULED: <2016-08-31 Wed ++1w>
    SCHEDULED: <2016-08-26 Fri ++1w>

Eventually, I tried this, and it worked:

*** water plants (1,3,5)

**** RECURRING water plants (1)
     SCHEDULED: <2016-08-29 Mon ++1w>
**** RECURRING water plants (3)
     SCHEDULED: <2016-08-31 Wed ++1w>
**** RECURRING water plants (5)
     SCHEDULED: <2016-08-26 Fri ++1w>

All three occurrences now show up on my agenda. However, this solution seems very inelegant, and perhaps may be problematic. Is there a neater, more effective way to do achieve the same result?


texts: Org-mode: C-c a is undefined but I have set key in config

texts:
I am a new user of emacs org-mode. I am getting an error when trying to get into agenda mode:

C-c a is undefined

My ~/.emacs looks like this:

(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-cb" 'org-iswitchb)

(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))

And I believe the files are in the correct directory structure because if I M-x into org-agenda manually, the agenda correctly shows the calendar items in my file. I am starting from the file:

GTD_todo.org in ~/org/

And my config is:

.emacs in ~/org/

I am using Cygwin64 on a Windows 10 machine. Thanks!


texts: doom emacs "Symbol's function definition is void: make-treemacs-theme"

texts:
I'm using doom emacs with current commit c83e5e75e24706a0d6c15f3156d33b1c4f9dc365.
When I do SPC o p I get error

Symbol's function definition is void: make-treemacs-theme

Below is the screenshot -

How can I fix this issue?


texts: Can Emacs be set to auto-stage (preferably with --intent-to-add) new files?

texts:
I often add a new file to a repo, make some other changes, then stage all, and commit all, forgetting that the new file is not yet tracked, so is not included in the stage all step. At least one editor (IntelliJ) has an option to auto-stage new files, which would be very helpful to me in Emacs. I guess this would be particularly helpful if it invoked --intent-to-add.
Is this feature present in magit or built-in in Emacs?
If not, I'd be interested in writing some elisp. Is there a hook run when magit sees a new untracked file, or would I have to add to the after-save-hook and query the git status?