texts: Making it so that cursor movement after command will deactivate region

texts:
I'm overriding double-mouse-1 to do additional stuff on top of its default behavior. To this end, I have a function that (1) does my additional stuff and then (2) calls another function, ora-mark-like-double-mouse-1, which simulates normal double-mouse-1 behavior (copied from here).

(transient-mark-mode t)

(defun ora-mark-like-double-mouse-1 ()
  (interactive)
  (let ((bnd (mouse-start-end (point) (point) 1)))
    (goto-char (car bnd))
    (push-mark)
    (set-mark (point))
    (goto-char (cadr bnd))

    ; The addition of this line produces a different,
    ; but also wrong effect, in which the selection vanishes
    ; immediately after appearing.
    (setq deactivate-mark t)
  )
)

(global-set-key [(double-mouse-1)] 'ora-mark-like-double-mouse-1)

However, this function is slightly flawed. It selects the clicked-on word as the region, but afterwards, any non-shifted cursor movement I do with the arrow keys causes the existing region to be expanded, rather than deactivated. This is different from normal double-mouse-1 behavior. This happens even if I just bind this function directly to double-mouse-1, as I do in the code above (in which I have temporarily removed my own extra functionality, and I have added a call to (setq deactivate-mark t), which causes the selection to vanish immediately after appearing -- which is not the correct behavior either).

Is there a way to set it so that, after calling this function, which selects a region, subsequent non-shifted cursor movement will cause the region to be deactivated?

Alternatively, if there some way to set up a hook to run after a double-click event, I wouldn't need to override and reimplement the default functionality at all. (It would also solve the problem that the linked-to function doesn't work when I double-click on the opening quote.)


texts:
windows 10, emacs 26.1

When I use I-search, then Emacs ignore case sensitive.

but I need case sensitive I-search


texts: What effect does eval-and-compile have on a defun-within-let?

texts:
The byte-compiler does not currently seem to recognise that a function has been defined when using defun within a let expression under lexical-binding, as explained in Stefan's answer to this question.

In my own initialisation file, I have found that I can make the defun-within-let obvious to the byte-compiler by wrapping the whole form in eval-and-compile, as I noted under the same question.

My multipart question is:

What further effects (desirable or otherwise) does placing the defun-within-let within eval-and-compile have compared to the bare version w.r.t. interpretation/byte-compilation/macroexpansion, etc.
I roughly understand by looking at the definition of defun that it is a glorified wrapper around defalias. Apart from forgoing the explicit (lambda () ...) (or other function value) which needs to be passed to defalias, is there some other subtle difference between defalias and defun, e.g. different treatment by the byte-compiler?


texts: default directory is not working in Windows

texts:
I am trying to set the default directory to D:/ by

(setq default-directory "D:/")

but when I type c-x c-f, it is showing D:\software\emacs\bin, which is the installation directory.


texts: Does ctags know about the type of a data member in a class?

texts:
I'm trying to learn about ctags in emacs.  I have built a TAGS file as per the instructions here: https://www.emacswiki.org/emacs/EmacsTags.  I think I'm using exuberent-ctags, but I'm not sure.

I have a large code base around statistical models.  Many classes have data members of the form

MySmartPointer<SomeModelType> model_;

This would be in a header file.  In the associated .cpp file I'll see code like

model_->do_something();

I'd like to press M-. and have emacs take me to the definition of model_.   Instead, I'm getting a long list of all the data members everywhere named model_, which is a very long list.

My questions are these:

Are my expectations realistic?  I.e does the ctags system contain enough information to know that the model_ I'm clicking on belongs to the class whose member function I'm editing?
Is there an obvious configuration step that I have missed?  I create the TAGS file using ctags -e -R --extra=+a.  (I've tried with and without the --extra flag).
(Added later) If making TAGS work this way is hard, what should I be looking at instead?  I assume I'm not the first person to need this functionality.

Thanks.


texts: Is there a way to get copy & paste to be context-aware wrt whitespace and formatting?

texts: When I copy a word and paste it at the end of an existing sentence (between the last word and the full stop), I'd like it to be pasted in such a way that the space between the pasted word and the previously last word is automatically inserted.  Similarly, when I copy a word with spaces around the words, I'd like the spaces to be automatically removed if they are not necessary (i.e. if there would be too many).  Basically, I always want a properly formatted text without having to think about white spaces (similar to typo-mode). Does something like this exist?  For context, I'm using evil but I suppose this would also be useful for users of plain Emacs.


texts: Are there implicit evaluation rules for backquoted structures?

texts:
I was constructing a macro that nested another macro and I ran into something that confused me. If the backquoted macro was the last form in the defmacro it evaluated as expected. If added an additional result it wouldn't work without an explicit eval. I've written some toy examples to illustrate my confusion:

(defmacro my-test-macro (arg1)
  `(format "we have %s" ,arg1))

(defmacro my-test-macro2 (arg1)
  (let ((part1 `(format "we have %s" ,arg1)))
    (format "this is outside quote (%s)" part1)))

(defmacro my-test-macro3 (arg1)
  (let ((part1 (eval `(format "we have %s" ,arg1))))
    (format "this is outside quote (%s)" part1)))

(my-test-macro "test1")
"we have test1"

(my-test-macro2 "test2")
"this is outside quote ((format we have %s test2))"

(my-test-macro3 "test3")
"this is outside quote (we have test3)"

So was it bad practice not to eval the result for my backquote? In the wider context of elisp macros do they tend to just return a single form which gets automatically evaluated?


texts: Copy current line if there is no active region

texts:
I wrote this custom function to copy the entire line, if no mark is set

(defun sk-copy-ops (beg end)
  (interactive "r")
  (if mark-active
  (kill-ring-save beg end)
  (kill-ring-save (line-beginning-position) (line-end-position))))

I am seeing two issues,

1) It copies from the current point and not from the beginning of the line

2) And when i keep my point on the last but one line in the above code and do M-x sk-copy-ops, it copies from the Point to the end of the buffer.

Are line-beginning/end-position not the right indicators of the begin/end of lines in buffer?


texts: Haskell code execution in Org-mode give error but in .hs file the code is good and working

texts:
i have this code:

  qs [] = []
  qs [x] = [x]
  qs (x:xs) = qs [a | a <- xs, a < x] ++ [x] ++ qs [b | b <- xs, b >= x]

when i save it to some file .hs and load it to ghci i can execute qs with a list of numbers without a problem.

but in Org-mode it give me error: *** Exception: <interactive>:16:1-56: Non-exhaustive patterns in function qs

the code block looks like this:

#+BEGIN_SRC haskell
qs [] = []
qs [x] = [x]
qs (x:xs) = qs [a | a <- xs, a < x] ++ [x] ++ qs [b | b <- xs, b >= x]
qs [2,9,3,8,4,7,5,6]
#+END_SRC

it's the same code as in the .hs file except the last line that execute an actual qs function.
how can i successfully execute this block?


texts: Split window with new buffer and spawn a new shell in same (possibly remote) directory as old buffer

texts:
In tmux, I can press some key combination and split the current window into two windows in the same directory.

I've tried the split-window-* function, but found it just duplicates the same buffer in emacs, so you end up with two windows that are each mutually synced to be identical. Not exactly what I had in mind...

You can get around this using (eshell 'N), but that only seems to work for eshell. I think I found some more complicated approach involving renaming buffers for shell, but I still couldn't get it to automatically cd into the directory I was in at the time I split the window.

I found some approach suggested on the emacs wiki where you configure the prompt to show you your full directory and parse it.

https://www.emacswiki.org/emacs/ShellDirtrackByPrompt

It seemed strange that no one's come up with a better way to track what directory you're currently in than to send to the prompt and parse the result, so I figured I'd ask this one more time just in case something's changed or someone has a way to do this without the prompt parsing hack. Also, a lot of those prompt parsing hack solutions were suggested quite a while ago, and maybe something's new in Emacs 26 that solves this problem.

Ideally, I'd like to be able to track remote directories too, but I'd be relatively happy if I could just get this to work for local directories.

I'm still pretty new at emacs, but getting this part in place would make it a lot easier to switch over and make it my default development environment.


texts: Emacs org mode entitiespretty not complete

texts:
This
#+STARTUP: entitiespretty

in my org mode buffer allows Latex/MathJax symbols to render in situ . . . almost. I type, e.g., $\le$ and instantly the markup is replaced by the actual symbol. There are some symbols, however, that don't render -- although they do appear as expected in an export. This isn't a huge problem, but why does the buffer balk on, say, `$\bot$) or $\mapsto$?


texts: Saving file everytime leaving insert mode in evil-mode

texts: Is there a way that I can automatically save the file when leaving insert state to go to normal state with ESC?


texts: Is this a normal behavior for *Flycheck error message*’s display?

texts:
The following is an example of how my flycheck errors show up on emacs:

Method name &quot;createQATask&quot; doesn&#x27;t conform to
&#x27;[a-z_][a-z0-9_]{2,30}$&#x27; pattern [invalid-name]

Here are the checkers I’m running (checked through C-c ! v):

Syntax checkers for buffer __manifest__.py in python-mode:

First checker to run:

  python-flake8
    - may enable:         yes
    - executable:         Found at /usr/bin/python3
    - configuration file: Not found
    - `flake8' module:    Found at "/home/devdesk4/.local/lib/python3.5/site-packages/flake8/__init__.py"
    - next checkers:      python-pylint, python-mypy

Checkers that may run as part of the first checker's chain:

  python-pylint
    - may enable:         yes
    - executable:         Found at /usr/bin/python3
    - configuration file: Found at "/home/devdesk4/.pylintrc"
    - `pylint' module:    Found at "/home/devdesk4/.local/lib/python3.5/site-packages/pylint/__init__.py"
    - next checkers:      python-mypy

Checkers that could run if selected:

  python-pycompile  select
    - may enable:    yes
    - executable:    Found at /usr/bin/python3
    - next checkers: python-mypy

I’ve tried disabling python-pylint’s configuration file, but the behavior still remains. I’ve also tried a minimal .emacs configuration which only contained the following:

(setq package-archives
      '(("gnu" . "http://elpa.gnu.org/packages/")
        ("marmalade" . "http://marmalade-repo.org/packages/")
        ("melpa" . "http://melpa.milkbox.net/packages/")
        ("melpa-stable" . "https://stable.melpa.org/packages/")))

(use-package flycheck
  :ensure t
  :init
  (global-flycheck-mode t))

Are those symbols (&quot;, &#x27;) not being displayed properly, or is this some sort of default flycheck configuration that I can override?

April 25, 2020 Update (Possible Solution)

Weirdly, I executed pip install --upgrade pylint just to check if I really had the latest version of pylint, and it upgraded from 2.3.0 to 2.4.4, and that fixed the issue.

However, this solution conflicts with using https://pypi.org/project/pylint-odoo/, because it reverts me back to version 2.3.0 which has those html-escape sequences.

Same-day update

It’s confirmed to be an upstream bug in Pylint.


texts: subdirectories in org-directory for org-agenda-files

texts:
Somehow this works fine:

(setq org-agenda-files '("file1.org" "file2.org" "subdir/file4.org"))

and this doesn't:

(setq org-agenda-files '("file1.org" "file2.org" "subdir/file3.org" "subdir/file4.org"))

throwing Non-existent agenda file subdir/file4.org.  [R]emove from list or [A]bort?

Why?


texts:
I've just set up mu4e, and have noticed that when opening an attachment with the o key it will open with MuPDF. Pressing A w to open-with doesen't seem to help either, since it prompts for an external shell command.

I'd like to open PDF attachments with pdf-tools instead of MuPDF, or at least be able to open with with the open-with function mapped to A w


texts: Switch ignore timestamp option dynamically in org-agenda

texts:
I want to use some variations of ignoring timestamp options in org-agenda.

For example, I want to have custom agenda command enumerates

TODOs Scheduled today
TODOs tagged some tag only within future 2 weeks
all TODOs regardless of timestamps

Are there some good way to realize this? (I imagine doing like let-ting org-agenda-ignore-* variables in each custom search options.)


texts:
When reading an email notmuch-(show)-mode unpacks zip files by default in my Emacs.

Is there a way to deactivate this behavior?

It's less of an issue for small zip-Files but I frequently send files that contain large binaries and this slows down the mail opening process considerably.


texts: How to control appearance of extra cursors?

texts:
I've just switched to “I-beam” cursor shape, it's set this way:

(setq-default
 cursor-type '(bar . 1)
 cursor-in-non-selected-windows nil)

But when I create additional cursors they are displayed as filled boxes
(while “main” cursor is displayed according to my settings). This doesn't
look good.

Is there any way to control appearance of additional cursors? Ideally, they
should mimic appearance of “main” cursor.


texts: Why does emacs come packaged with games and amusements?

texts:
This question has confounded me ever since I was a freshman in college trying to subtly bludgeon my way through Dunnet in the lab without my professor noticing. Why in the world does emacs come with games and amusements? Why include games in a text editor?

For this question, I'm looking for an accurate historical summary. Were there games present in emacs from the very beginning? Were silly amusements always intended as a feature? Did someone package the very first included game in as a joke and everyone ran with it? Is it a mystery lost to the sands of time?


texts: Request an object other than a string from the user (with completion)

texts:
I have a list of objects and I want the user to pick one of them (with completion). But these objects are a priori not strings, so I can't use completing-read. What should I do ?

Example In the following example I want to write the interactive spec for killing a process, so I want the user to pick a process to kill.

(defun yf/kill-process (process)
  (interactive (list (let ((list
                            (mapcar
                             (lambda (proc)
                               (cons (format "%s" proc) proc))
                             (process-list))))
                       (cdr
                        (assoc (ido-completing-read "Process: "
                                                    (mapcar #'car list))
                               list)))))
  (when (yes-or-no-p (format "You are about to kill process \"%s\", continue? " process))
    (delete-process process)))

This is something I have to do often, so I'm wondering if there's a standard way to achieve this functionality (or if I should write my own... which I have done already, but it's ugly).


texts: How to call `org-sparse-tree` from Lisp?

texts:
While viewing org-mode files I am used to typing , - / t to produce a sparse tree of todo items.
I am trying, unsuccessfully, to write some Lisp to achieve the same thing.
Here's the sort of thing I'm playing with, added to my init file:
  (defun my-sparse-todo ()
    (interactive)
    (org-sparse-tree nil "t"))

  (define-key evil-normal-state-map [f10] 'my-sparse-todo)

If I run this by hitting f10, I am prompted to enter the sparse tree type character.
What am I doing wrong please?


texts: GNU global prefers goto definition instead of goto to declaration

texts:
How I find a declaration of a cpp class or struct by GNU global for now.

search a class name with Emacs gtags plugin such as ggtags or counsel-ggtags)
the constructor or destructor of the class is found
search the class name again, this time references will be displayed
grep for the class declaration among thousands references which kills me

How can I find the declaration of a class or struct by GNU global in a more efficient way.
I can find the declaration by xref-find-definitions with ctags database easily,
however ctags is slower than gtags.


texts:
Is there a package that can tell me the arguments for c++ constructor?

class T1 {
    public:
        T1(int x, int y);
};

T1::T1(int x, int y) {
    std::cout << x+y << std::endl;
}

int main() {
    T1 h1(5, 5);
    return 0;
}

For example when I write T1 h1( it informs me the constructor takes int x and int y.


texts:
Why am I getting these results?

(+ 5.2   42.4   -1) 46.6
(+ 5.2   42.45   -1) 46.650000000000006

Couldn't the 2nd operation just output 46.65? Where does the 0000000000006 come from?


texts: Coding System utf-8 on Mac - Which one and why as default?

texts:
I want to change my default encoding system from non defined to UTF-8 (I think that would be useful). Now I have seen many different UTF-8 coding systems:

mule-utf-8        mule-utf-8-dos
mule-utf-8-mac    mule-utf-8-unix
prefer-utf-8      prefer-utf-8-dos
prefer-utf-8-mac  prefer-utf-8-unix
utf-8             utf-8-auto
utf-8-auto-dos    utf-8-auto-mac
utf-8-auto-unix   utf-8-dos
utf-8-emacs       utf-8-emacs-dos
utf-8-emacs-mac   utf-8-emacs-unix
utf-8-hfs         utf-8-hfs-dos
utf-8-hfs-mac     utf-8-hfs-unix
utf-8-mac         utf-8-unix
utf-8-with-signature     utf-8-with-signature-dos
utf-8-with-signature-mac utf-8-with-signature-unix

I am using a Mac and I am further confused about these different hfs and mac coding systems.

At the moment I decided to use utf-8 as follow based on this answer:

(setq utf-translate-cjk-mode nil) ; disable CJK coding/encoding (Chinese/Japanese/Korean characters)
(set-language-environment 'utf-8)
;; (set-keyboard-coding-system 'utf-8-mac) ; For old Carbon emacs on OS X only
(setq locale-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(unless (eq system-type 'windows-nt)
  (set-selection-coding-system 'utf-8))
(prefer-coding-system 'utf-8)

But I would like to understand some more what I am doing and why another utf-8 would be better as a default coding system?


texts: How can I resize certain windows evenly when using the golden-ratio library?

texts:
I'm using golden-ratio and ediff.

I want golden-ratio-mode turned off when using ediff and turned on after I finish merging with magit.

I cannot figure out a way to evenly balance Ediff's windows (A, B and C).

(use-package ediff
  :ensure nil
  :init
  (add-hook 'ediff-before-setup-windows-hook
            (lambda ()
              (golden-ratio-mode -1)
              (balance-windows)))
  (add-hook 'ediff-cleanup-hook (lambda () (golden-ratio-mode 1)))
  :config
  (setq-default
   ediff-split-window-function 'split-window-horizontally))

What am I missing?


texts:
I have installed paredit & need to turnoff smartparens. I checked this answer and  I have added

(advice-add #'smartparens-mode :before-until (lambda (&rest args) t))

to my prelude starter kit. Now when I restart emacs I get this error

Symbol's function definition is void: advice-add

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.

When i run emacs with

emacs --debug-init

I dont get any errors or backtrace. It starts normally & everything is working fine.

But when i start emacs directly same error occurs. Can someone tell me how to debug this?

Update: my emacs config.


texts: Use helm fuzzy search inside ranger inside spacemacs

texts:
I am using ranger within spacemacs. One useful feature an explorer in windows (directory opus) I used has, is that by pressing keys it automatically starts to filter files with names corresponding to the keys.

Is there a way to use helms fuzzy search as the default mode inside ranger windows, which then filters the files and directories according to the fuzzy input and to be able to toggle the mode off when desired?


texts:
Is there a way to get elisp to automatically treat all numeric variables as floating points without having to repeatedly use the float function?

For example to a division function that outputs the "true" quotient is

(defun divide ( x y )
  (/ (float x) y))

But I'd rather not have so many float functions floating around (even if, given the name, that's a part of the function's essence ;) ).


texts: Enabling `flyspell-prog-mode` starts `flyspell-mode` instead

texts:
I've been playing with flyspell lately and with my recently established setup for spell-check, I wanted to enable it for all modes. I found that flyspell-mode and flyspell-prog-mode are best for text-mode and prog-mode respectively and found in an answer to a similar question that it can be done as:

(add-hook 'text-mode-hook
          'flyspell-mode)
(add-hook 'prog-mode-hook
          'flyspell-prog-mode)

I've done the same thing but have noticed that for both the cases, flyspell-mode gets enabled and the flyspell-prog-mode doesn't get enabled at all. My code can be found here and it's the exact same as suggested.

Any help would be appreciated.


texts: Org based init method slows down emacs startup DRAMATICLLY (6 minute startup)..help needed

texts:
So after a few months of frustration today i discovered the issue that's been bothering me for a long time..the REALLY slow emacs startup (sometimes 5 minutes or more).

The cause is the org mode init file i use. what i currently have in my setup is

A. this init.el:

(require 'package)
;since we are using use-package-don't autoload anythings
(setq package-enable-at-startup nil)

(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
;; org maybe suspect of hanging melpa, if you have hangs disable this first
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
;; Initialize installed package
(package-initialize)

;; Bootstrap `use-package'
(unless (package-installed-p 'use-package)
    (package-refresh-contents)
    (package-install 'use-package))

(org-babel-load-file (expand-file-name "~/.emacs.d/settings.org"))

B. My config stored in settings.org which alot  of lisp code (like 17,000 lines..yeah i like to tinker :))

Using this method i discovered that every time i make a small change to setting.org and restart emacs the setting.org gets tangled to settings.el and emacs takes nearly 6!!! minutes to start (Init time was 396.10s (395.33s in init.el) , yeah thats painful as you can imagine.

BUT what i discovered today is that if i just stick my config chunks from setting.org (ie the tangled setting.el file) into init.el, emacs starts super fast each time, even when i change the init.el file!

can anyone help me with this, i really would appreciate you guys help with this as its driving me mad :)


texts: How to control where the org todo keywords buffer displays?

texts:
Q: how can I control where the org todo keywords buffer appears?

Entering a todo keyword with C-c C-t (org-todo) opens a new
buffer with the keyword options and then closes it again after I
select one.  So far, so good.  However, it takes over another
window to do so, which is less good, especially since it really
only needs to display a line or two with the keywords.

So, with the following layout, hitting C-c C-t while in the left
window (some-org-buffer) will open *Org todo* in the right
window:

+---------------------+---------------------+
|                     |                     |
|                     |                     |
|                     |                     |
|                     |                     |
|   some-org-buffer   |  some-other-buffer  |
|                     |                     |
|                     |                     |
|                     |                     |
|                     |                     |
+---------------------+---------------------+

Instead, I would like to have a small window pop up as a vertical
split, as below:

+---------------------+---------------------+
|                     |                     |
|                     |                     |
|   some-org-buffer   |  some-other-buffer  |
|                     |                     |
|                     |                     |
+---------------------+                     |
|                     |                     |
|     *Org todo*      |                     |
|                     |                     |
+---------------------+---------------------+

Cribbing from
this answer, I wrote a
function to put in the display-buffer-alist:

(defun org-todo-position (buffer alist)
  (let ((win (car (cl-delete-if-not
                   (lambda (window)
                     (with-current-buffer (window-buffer window)
                       (memq major-mode
                             '(org-mode org-agenda-mode))))
                   (window-list)))))
    (when win
      (let ((new (split-window win -5 'below)))
        (set-window-buffer new buffer)
        new))))

(add-to-list 'display-buffer-alist
             (list " \\*Org todo\\*" #'dan-org-todo-position))

However, that fails to work.  Sigh.  What have I done wrong with
the display-buffer-alist?  More to the point, how do I get my
todo keyword buffer to pop up where I want it?


texts: How do I insert inline code with square brackets in org-mode?

texts:
I would like to include some examples of regular expressions in an org-mode file. I would like to write ~[[:whitespace:]]~.

However, [[:whitespace:]] is interpreted as a footnote/link, regardless of the syntax:

[[:whitespace:]]

~[[:whitespace:]]~

=[[:whitespace:]]=

I've also tried escaping the brackets \[\[:whitespace:\]\] but that just shows the \ in my org-mode buffer.

How can I write [[:whitespace:]] in inline code?


texts: How to match only a word when using `re-search-backward` function

texts:
I want to replace a character inside a word, so I wrote:

(setq regexp "[ab]")
(and (re-search-backward regexp nil t 1)
     (replace-match "c"))

This replaces a or b to c as I wish, but I want to set a bound of it.
There is a BOUND option with re-search-backward.
How can I make the match only a word that is under the current cursor?

Thanks for @jackson I can write the function, but still it doesn't work properly.

(setq regexp ".*[ab].*")
(defun test-it ()
  (interactive)
  (save-excursion
    (save-restriction
      (narrow-to-region (progn (backward-word) (point))
                        (progn (forward-word) (point)))
      (and (re-search-backward regexp)
           (replace-match "c")))))

Thins function replaces ab to ac and ad to cd as I expected, but it doesn't replace ac to cc. Why?


texts: Move cursor to Start of document/End of document on OSX

texts:
On Linux, I am able to move the cursor to start of buffer/end of buffer using using C-Home/C-End respectively:

C-End       Move cursor to the end of the buffer. Note the key is 'End' key on the keyboard.
C-Home      Move cursor to the beginning of the buffer.

However, on Mac OSX, I am unable to perform this simple operation. First, there is no HOME or END key. Second, supposedly, these keys are supposed to be the substitute:

begin   M-<     ⌘↑
end     M->     ⌘↓

But M-< and M-> are reserved for something else. And ⌘↑ and ⌘↓ are undefined. Only experience this issue with OSX. How should I resolve it?


texts: Is it possible to ignore paste operation during `C-x C-x` to jump back?

texts:
This question is related to Is it possible to bind C-u C-x C-xs behavior into C-x C-x. My main goal is to jump top of the file, type import  and paste a package name and jump back where I was.
Scenario:
I am on the line 10 and copied a word. Than I press M-<to jump top of the file, move down to line 1 and typed import  and pasted the copied word. Now when I press C-x C-x, it jumps to the starting point of the pasted word and if I press again it jumps to end of the paster word in the line 1.
0                                     | <= jumped here and go one line below
1                                     | import hello_world  # (2) type import and
2                                     |                       paste hello_world \
3                                     |                                         |
4                                     |                                         |
5                                     |                                         |
6                                     |                                         |
7                                     |                                         |
8                                     |                                         |
9                                     |                                         |
10 hello_world()  # (1)cursor is here | <= (3) I want to jump back here <--------

At this point, I just want to jump pack to point where I was (which is line 10), how can I acheive it?


texts: Bongo music player won't play next track in sequence

texts:
The new version of Totem removed the playlist feature, so I'm looking for a simple way to choose 2 or 3 podcasts from a selection of 12 or so recently cached to a ~/Podcasts directory.

The bongo music player looks simpler than EMMS, and although like EMMS it doesn't support sort-by-date in the library, it does hook into dired so I can sort most-recently-downloaded to the top in there.

Unfortunately I can't get it to play tracks continuously.

I queue a track to the playlist by pressing e in a dired buffer. I then press e with the point on another file in the dired buffer. There are now two tracks queued in the playlist buffer.

With my point on the first track I press RET and the track starts playing. When it ends, the audio stops. It does not start playing the next track in the playlist.

bongo-next-action is the default bongo-play-next-or-stop, but I've tried setting it to bongo-play-next, like so:

(setq-default bongo-next-action #'bongo-play-next)

I've tried C-u C-c C-n but that seems to makes no difference.

How do I make Bongo play more than one track without intervention?

I am using Emacs 24.4 on Linux, and mpg321.


texts: Is there a mode-hook when you switch to a buffer in Eshell mode

texts:
For my function, that I have created, I'm looking for an Eshell mode hook.

I'm aware of the following hook:

(add-hook 'eshell-mode-hook 'my-function-for-eshell).

But what when I'm in a other buffer and want to switch back to the existing buffer with Eshell mode, I want to run that function?
But I found all the hooks only will be triggered, when you create a new buffer with an Eshell mode.

To be clear, I run Evil normal mode when I do switch buffers with a keybinding in normal mode.
The my-function-for-eshell brings me back in Evil insert mode, when I go back to Eshell.


texts:
the following alias in the aliases file doesn't work in eshell 2.4.2, emacs 24.4.1

  alias ff 'find-file $1'

error message as is is given below

  find-file $1: command not found

Any ideas what is going wrong?


texts: Wait for release a key to go on in a loop

texts:
I have this loop:

(catch 'QUIT
  (while
      (search-forward-regexp "\\([^\n\\]\\(?:\\\\\\\\\\)*\\|^\\(?:\\\\\\\\\\)+\\)%.*\n"
                 nil t)
    (save-excursion
          (let ((b (make-marker))
        (e (make-marker))
        MatchedStringOverlay
        ACTION)
        (set-marker b (match-beginning 0))
        (set-marker e (point))

        (setq MatchedStringOverlay (make-overlay b e))
        (unwind-protect
        (progn
          (overlay-put MatchedStringOverlay 'face '(:background "OliveDrab1"))
          (setq ACTION (read-char "Options:
- [y] erase string and the corresponding \"newline\"
- [l] erase string keeping the corresponding \"newline\"
- [n] skip
- [q] quit:
"))
          (cond
           ((char-equal ACTION ?y)
            (replace-match "\\1"))
           ((char-equal ACTION ?l)
            (replace-match "\\1\n"))
           ((char-equal ACTION ?n)
            nil)
           ((char-equal ACTION ?q)
            (throw 'QUIT nil))
           )
          )
          (remove-overlays b e))
        )))
  )

It work fine for my purposes but it would be better if I could get this behaviour: Let's say I chose the [y] option, I'd like to perform the replacement but "pause" the loop until the [y] key is released. The best would be if, while pressing [y] I could undo the action pressing another key (e.g. [u]).

I'm, obviously, not asking you to write the code for me, but I'd like to know if it is possible to get what I figured out and, if so, what to look at.

EDIT. I figured out a simpler way to get way to get what I need, buy using lowcase or Uppercase version of char but I'm also interested to learn about events.


texts: With "japanese" input method, unmap kanji selection via the spacebar?

texts:
In emacs-26.1, I am enabling the Japanese input method as follows ...

(toggle-enable-multibyte-characters 1)
(set-language-environment "Japanese")
(set-input-method "japanese")
(setq coding-system-for-read 'utf-8-unix)
(setq coding-system-for-write 'utf-8-unix)

This works fine and gives me hiragana characters when I enter their romaji equivalents, but SPC is mapped to a selection dialog for kanji characters. I want SPC to be mapped simply as self-insert-command, and I'd like to remap the kanji selection dialog to a different key sequence.

I tried the following, but it had no effect ...

(define-key kkc-keymap " " 'self-insert-command)
(define-key kkc-keymap "\C-^" 'kkc-next)

SPC still got me into the kanji selection dialog, and C-^did nothing.

I'm not sure, but it seems like there is code somewhere in kkc.el which forces kkc-next to be mapped to SPC, no matter what.

Short of completely rewriting some of the code in emacs-26.1/lisp/international/kkc.el, is there any way to remap the kanji selection dialog to something other than SPC?


texts: Configure the delay before window showing command completions is shown

texts:
When I start entering a command and pause, this helpful window pops up at the bottom:

When I don't pause, it doesn't show up.

But sometimes, it takes more time to complete a command that I know, e.g. if it requires me to access modifier keys like shift or control.

In those cases, this window briefly flashes and disappears, often also freezing up the editor for about half a second or so.

How can I increase this pause time so I'm only shown the command completions if the pause is longer than, say 2 seconds?


texts:
I frequently forget to start my X server before I fire up emacs. Obviously emacs will attempt to open an X window and fail.

In older versions of emacs (I forget when this changed) the behavior was an error message and emacs would exit. In current versions of emacs there is an error message and then emacs starts up in no-window-system mode.

How do I restore the older behavior?


texts: Why is it convention to have `(provide )` at the bottom of the file?

texts:
I've been looking through some elisp libraries and most calls to provide happen at the end of the file.  In clojure the ns is quite similar to provide.

I've noticed that putting provide at the top of the file makes no difference. Is there a reason for putting it at the end vs at the top?


texts: Insert a list of lists of strings as CSV

texts:
Given a list of lists, as returned e.g. by pcsv-parse-buffer, what's a correct way of inserting it to the buffer in CSV format ?

I looked at pcsv.el and csv-mode.el but could not find a function to do that.

I think the main point is to correctly escape commas and double-quotes within each field.


texts: How to make a specific read-only buffer writable?

texts:
The readonly status of the current buffer can be toggled with (read-only-mode) or pressing C-x C-q but I intend to make a buffer which is not current, writable. The below is what I am using

(with-current-buffer (get-buffer-create "*some*")
    (read-only-mode nil))

hoping that it would remove the readonly status applied on the buffer '*some*', however it only sets the readonly status again to the buffer. Visiting the buffer and pressing C-x C-q does work but that is not what I intend to do, I need to do it remotely.


texts: How to ignore ispell on comments in the LaTeX-mode

texts:
I am working on tex files with LaTeX-mode. I want to disable flyspell on comments and if possible latex's unique keywords such as \iffalse, \fi, \IEEEpeerreviewmaketitle, etc.

I have followed this answer but seems like it did not have any affect:
(setq ispell-check-comments nil). I am not sure what I am doing wrong.

I have following setup:

(setq LaTeX-item-indent 0)
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)
(require 'tex)

(setq flyspell-issue-message-flag nil
      ispell-check-comments nil
      ispell-local-dictionary "en_US"
      ispell-program-name "aspell"
      ispell-extra-args '("--sug-mode=ultra"))

(flyspell-mode 1)


texts: org-mode: Can I use a custom mode for org-src-lang-modes and still get syntax highlighting?

texts:
I'm trying to get syntax highlighting with org-mode source blocks using a custom language mode for editing JavaScript. I use js2-mode with a bunch of minor modes, rather than js-mode, which is what org-mode uses by default.

I was able to get org-mode to use js2-mode for editing code by customizing org-src-lang-modes, where I set the Cons-cell for javacript to js2.

However, syntax highlighting has stopped working in the org buffer (it works fine in the source buffer). This is with org-src-fontify-natively set to true, which the documentation suggests is the only requirement.

Is there anything I'm missing?


texts: How to modify a string without altering its text properties

texts:
If I propertize a string and save it to a variable, how can I change the string within that variable without altering its text properties? For example:

(setq myvar (propertize "testing"
                        'property1 "this is property1"
                        'property2 "this is property2"))

I would like to change the string of myvar to "mystring" without changing its properties.


texts: Fixed-width space character with a variable-width font?

texts:
Is it possible to display a space with a monospace font, while displaying all other characters with a variable-width font?

I tried

(set-fontset-font t '(#x20 . #x20) (font-spec :family "Source Code Pro"))

but the result was an error message saying

Can't set a font for partial ASCII range

Is this completely impossible, or am I doing the wrong thing?


texts: How do I get Emacs to recognize my python 3 virtual environment

texts:
My system is macOS and I have both python 2 and 3 installed. I am currently working on a side project for which I want to use Django 1.8 and python 3.4.

I have created a virtual environment with the python 3 command pyvenv venv in the parent folder of my project (I prefer to have my python project folders to be self contained).

At the moment, I cannot get Emacs to recognise and therefore limit all code related assist to the virtual environment.

In addition, is it possible to setup per-project settings such that I can have different projects use different python versions and environment? The ideal scenario will be, when I change into a project directory and start Emacs, it will pick all it's environment settings from that project directory according to some local settings file.


texts: Is there a simple way to insert an org-mode link directly from the system clipboard? I'm thinking of selecting an URL in Safari, and inserting that link directly in an org-mode document.


texts: Dired buffer's cursor change of behavior in dired+

texts:
I have in the past been using

(require 'dired)
(require 'dired-x)

quite happily. Recently I've been even happier after switching to

(require 'dired)
(require 'dired-x)
(require 'dired+)
(require 'icicles)

except for two issues:

I was formerly able to copy the current directory by moving the cursor to the top of the buffer and pressing 'w' (for subsequent yanking/pasting somewhere else). Now that top line (the current directory) is off-limit. How do I recover copying the current buffer in dired+/icicles? (The C-0 w trick no longer works.)
While navigating up in a directory chain, I found easier to type 'q' (M-x quit) rather than '^' (M-x diredp-up-directory). 'q' still brings back the parent directory, but drops the cursor to the bottom of the buffer, which makes it a lot less easy to navigate a directory chain. Even if '^' is more correct, and before I simply change the assignment of 'q', I'm seeking some understanding of what's happening. Why does quitting in dired+ move a dired buffer's cursor? Is it perhaps the case that the sequence of dired/dired-x/dired+/icicles introduces an incompatibility?


texts:
I have installed emacs 2-3 years ago. The version I'm using now is 25.2.1. I want to update it to the latest version, which is 27.1. I uninstalled it and then installed again to no avail, it is the same old version. I have googled it, read a few sites, even came over StackOverflow question. None of those sources was helpful. Also, when installing it, I do it so via MSYS. That MSYS also shows MinGW things when it installs. I also looked at path in Environment variables in MS Windows Settings. I don't understand those things; neither path nor MSYS or MinGW is comprehensible for an amateur like me. So, can you help me and other future amateurs who will look here for help?
How can I upgrade to latest emacs on Windows?
I'm using Windows 10 64-bit. Thanks.


texts: How to map CJK input to english alphabet for purposes of key bindings and evil?

texts: When I type in a CJK language, I would still like to be able to use emacs key bindings such as M-x, as well as vi keys in evil-mode normal-state. Is there a way to make emacs register the keyboard input as a US keyboard only when a modifier is pressed? Also, maybe more difficult, is there a way to make evil normal state register keypresses in the US keyboard (without manually mapping every single command to its CJK equivalent)?


texts: Unwanted characters in messages downloaded with RMAIL

texts:
I use RMAIL as my default Email client and it works well for my purposes. I have one small problem with it that I cannot resolve. Downloaded messages include unwanted characters in one heading, the Return-Path: heading. So a typical incoming email looks like this when RMAIL is running:
\377Return-Path: <example@email.com>

Note \377
If I open the actual RMAIL file, the line looks like this:
ÿReturn-Path: <example@email.com>

The Emacs Manual speaks of this problem but offers a vague solution by advising the user to "guess" the right encoding system.
https://www.gnu.org/software/emacs/manual/html_node/emacs/Rmail-Coding.html
I have tried various options but none seem to work.
I run Emacs 27.1 on Windows 10.


texts: How to assign a certain font for each input method/language in Emacs 24?

texts:
C-x RET \ or M-x set-input-method to select the text input method; e.g. I use greek and hebrew.

I must say C-\ is genius, because it brings you back to the default input which you use the most.

I want Emacs to automatically detect the entered text method and accordingly change the default font (font0 for English) as I enter the text input method to either font1 in case of Greek or font2 in case of Hebrew.

How to achieve this in Emacs 24.3.1 by Elisp in .emacs?

Note
Platform: Windows 7-32bit.

This is my trial:

(defun font-for-input ()
  (cond ((equal current-input-method nil)
         (face-remap-add-relative 'default :family "Consolas" :height 110))
        ((string-equal current-input-method "greek")
         (face-remap-add-relative 'default :family "Romans" :height 120))
        ((string-equal current-input-method "hebrew")
         (face-remap-add-relative 'default :family "DejaVu Sans" :height 120))
        )
  )
(font-for-input)

So there are three states:
nil: Consolas 11 or by hitting C-\ to deactivate set-input-method and return to default (English in my case)
Greek: change to Romans 12
Hebrew: change to DejaVu Sans 12

Interesting, this is my first code in Elisp! it works but clumsy. I want Emacs to automagically change these fonts as it detects the current-input-method if any? Any suggestions to improve the code (more consice) are appreciated.

Update
Ok, I admit this seems totally silly and impractical. I think what I need actually is 3 key bindings -- one for each language or input method (English, Greek, and Hebrew). Hitting either one should set-input-method to that language and change font accordingly and hook that to whatever buffer in current use -- be it text, org mode or TeX, etc. Any help?


texts: How to check if the cursor is inside an org-mode "src" block?

texts:
I'd like to know if a point is inside an org-mode src block, so I can disable spell checking.
Is there a fast way to programmatically check this?


texts: How should you read a Lisp file as Lisp for processing without condition-case?

texts:
To help catch predictable errors, I've written my own linting tasks that read the code and report any inconsistencies it finds.  One of the hackier pieces to this right now is the following function:

(defun lint-get-forms (filename)
  "Read FILENAME and return a list of its Lisp forms."
  (let ((pos 0) forms)
    (with-temp-buffer
      (insert-file-contents filename)
      (condition-case _
          (while t
            (when-let ((cell (read-from-string (buffer-string) pos)))
              (push (car cell) forms)
              (goto-char (setq pos (cdr cell)))))
        (error forms)))
    forms))

Is there a better way to do this (preferably without condition-case)?

Ideally these checks would be done at compile-time, but they're not stable enough yet to move to the other repository.


texts: Can Helm/mu4e learn which selection/contacts I use most often?

texts:
I'm using org-contacts as mu4e address book.  When I start typing an address in, say, the To: field and press TAB, I get a Helm buffer with possible completions, ordered alphabetically.

Is there any way I can make mu4e/Helm learn which addresses I use most often and order the matches by usage frequency?


texts: Can emacs be used for the same purpose of GNU Screen and Tmux?

texts:
GNU Screen and Tmux can make processes survive user's logging out, and resume when logging back again.

Can Emacs be used for the same purpose, and how?


texts:
I'm walking a directory tree upwards from default-directory in a loop, so I need a way to say "take the last component off this path that ends in a slash and return a result that ends in a slash". The closest built-in thing I found is (file-name-directory) and it's not a great fit. I ended up writing this:

(defun pop-dir (dir)
  "Pops a trailing directory off DIR to return the remainder of the path."
  (concat "/"
          ;; there's probably some better way to do this but ¯\_(ツ)_/¯
          (string-join (reverse (cdr (reverse (split-string dir "/" t)))) "/")
          "/"))

There has to be a better way; what is it?


texts: Auto-Indenting \if statements with AUCTeX

texts:
The current AUCTeX behaviour for primitive tex code involving if-like statements is to indent the conditional statement at the same level as the surrounding condition. I.e. code such as

\if@sometoggle%
\dosomething%
\else%
\doanotherthing%
\fi%

appears as a big block of text. I would like to make AUCTeX indent the snippet as follows:

\if@sometoggle%
  \dosomething%
\else%
  \doanotherthing%
\fi%

Is this possible?


texts: How to display Unicode bidi markers only in Whitespace mode?

texts:
There's a way of displaying Unicode bidirectionality markers. The problem is: it makes them visible all the time. Is it possible to show them only in whitespace mode?

PS I'm not chained to the method in the linked post. Any other way of displaying the Unicode bidi markers when in whitespace mode will be equally welcome.


texts:
I use company-statistics to sort completion candidates by previous completion choices. It works perfectly, except there is only tiny problem. The file ~/.emacs.d/company-statistics-cache.el pops up in recentf-mode and I'd like recentf-mode to not display this file. How can I achieve this ?

I added the path of the file to the symbol recentf-exclude but that did not help. I also tried adding the path of the directory itself and that didn't help either.


texts:
I am trying to write  emacs init using Org-mode By using org-babel-load-file function in init.el. My init.el file is

(require 'package)
(add-to-list 'package-archives
         '("melpa" . "https://melpa.org/packages/")
         '("marmalade" . "http://marmalade-repo.org/packages/")
         )
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(org-babel-load-file (expand-file-name "settings.org"
                   user-emacs-directory))

But on using so I am getting the following error message

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  expand-file-name(nil)
  load-file(nil)
  org-babel-load-file("/home/nithin/.emacs.d/settings.org")
  eval((org-babel-load-file (expand-file-name "settings.org" user-emacs-directory)) nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

I would appreciate any input on the subject.


texts:
I want to load the multi-web-mode package and have put it in ~/.emacs.d/ or ~/ or ~/.emacs.d/lisp/(so far).

My .emacs contains the standard from the multi-web-mode distribution:

(require 'multi-web-mode)
(setq mweb-default-major-mode 'html-mode)
(setq mweb-tags
  '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
    (js-mode  "<script[^>]*>" "</script>")
    (css-mode "<style[^>]*>" "</style>")))
(setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
(multi-web-global-mode 1)

I get:

File error: Cannot open load file, no such file or directory, multi-web-mode

I was expecting that emacs would search in some of my directories and automatically discover it.

When I add

(load-file "~/.emacs.d/lisp/multi-web-mode.el")

or

(add-to-list 'load-path "~/.emacs.d/lisp/")

to the .emacs file the emacs lisp file is loaded alright.

Is there really no user directory where the .el files are automatically loaded from? Would I always need to do (add-to-list 'load-path "~/.emacs.d/lisp/") everytime I setup emacs?


texts:
What handler is called when I make triple click ? For me, it select whole line. I want this behavior to be binded to C-l, how to do it ?

EDIT:

I tried to bind this to key, but not works, how to fix it?

(defun custom/mark-whole-line  ()
   (interactive)
   (mouse-start-end 0 (buffer-size) 2))


texts: Org-Agenda day agenda filtered by tags OR'ed

texts:
A custom Agenda view can be filtered by tags AND'ed, e.g. show entries having both play AND read tags, like this:

(setq
 org-agenda-custom-commands
 '(("p" "play AND read" agenda ""
    ((org-agenda-tag-filter-preset '("+play" "+read"))))))

What could be the way to display day agenda listing entries with either play OR read tags?


texts: What's the relationship between ~foo~ and =foo= in org-mode?

texts:
Both =foo= and ~foo~ seem to be used in org for inline bits of code. How do they differ? Which should I use, and when?

For example, from the ORG-NEWS file:

If you want to exclude a headline from export while using its contents
for setting options, use =:noexport:= (see =org-export-exclude-tags=.)

...

The key sequences =C-c C-n= and =C-c C-p= are now bound to
~org-next-visible-heading~ and ~org-previous-visible-heading~ respectively,
rather than the =outline-mode= versions of these functions.  The Org
version of these functions skips over inline tasks (and even-level
headlines when ~org-odd-levels-only~ is set).

There isn't an obvious pattern here: org-export-exclude-tags and org-odd-levels-only are both variables, and org-next-visible-heading and outline-mode are both functions.

Do either of these syntaxes support jumping to *Help* buffers the way `foo' does in docstrings?


texts: How to escape brackets in mu4e search queries?

texts:
Title says it all.

I want to have a search query which matches all messages whose Subject starts with [Spam].  So far, I tried the following:

[Spam]
[spam]
\[Spam\]
\[Spam\]
\\[Spam\\]
\\[Spam\\]

I'd appreciate any pointer in the right direction ...


texts: Set org-capture datetree write on top of the file

texts: I'm using org to store a list of links, I capture the links with org-capture and a custom template, but I want to write the new entries at top of the file. how I can do this?


texts: Git status on modeline to indicate if behind remote?

texts:
Can I get Emacs to indicate on the mode-line whether a push is needed, i.e. whether the repo is out of sync with origin?

I've already got it telling me if a commit is needed using vc-status, but that doesn't indicate whether the most recent commit locally has been pushed to origin.

(I've got something similar going on with my oh-my-zsh prompt via ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE, and I'd love to duplicate that within Emacs.)


texts: Building Emacs from source doesn't generate a native application on macOS Catalina

texts:
I've been trying to build Emacs 28 from source on my MacBook Pro running macOS 10.15.5. I managed to get the feature/native-comp branch working, but I found it to be too unstable, so I deleted Emacs and tried rebuilding off of the master branch.
Now when I build off of the master branch, I can't get the GUI'd Emacs to build. I've tried blowing away the source directory and rebuilding from scratch, but that didn't fix anything.
Here's how I build:
$ ./autogen.sh
$ ./configure --without-ns && make
$ make install

I worry I might have bungled deleting the old app. Any suggestions on what I might try next?


texts: YASnippet: Remove parts of expanded snippet when exiting the current active area based on condition

texts:
I want to write a snippet for LaTeX sum that behaves like this:
I write "sum" and trigger snippet expansion.
"sum" becomes "\sum_{$1}^{$2} $0", with $1 being the first entry point, $2 the second one and $0 the exit point.

If I write nothing inside $1, I want to have the "_{}" part deleted and proceed to $2.
Likewise with $2.

Is such a thing possible with YASnippet or any other snippet engine? I tried putting an Elisp function that deletes the needed part if exiting with no input made but it breaks the snippet.


texts: Setting the value of a variable in Org babel system-wide header arguments

texts:
The context
I always experiment with commands in the following path $HOME/trash/experimental. For this reason, I wanted to make all shell code blocks to use that directory as the default directory. I've already accomplished that by setting the following in my configuration
$ cat ~/.emacs.d/init.el
(org-babel-do-load-languages
 'org-babel-load-languages '((shell . t)))

(setq org-babel-default-header-args:shell '((:dir . "~/trash/experimental")))

Sometimes I also play with the zsh and the dash shell so I would also make the previous mentioned directory as the default one for code blocks whose language is any of those shells.  Similarly, I can accomplish that by setting the following in my init.el file.
$ cat ~/.emacs.d/init.el
(org-babel-do-load-languages
 'org-babel-load-languages '((shell . t)))

(setq org-babel-default-header-args:shell '((:dir . "~/trash/experimental")))
(setq org-babel-default-header-args:dash '((:dir . "~/trash/experimental")))
(setq org-babel-default-header-args:zsh '((:dir . "~/trash/experimental")))

As seen above, the path is repeated three times. In order to avoid that I defined a variable that stores the path where I experiment with commands (i.e. ~/trash/experimental). Thus, my configration file looks  like
$ cat ~/.emacs.d/init.el
(org-babel-do-load-languages
 'org-babel-load-languages '((shell . t)))

(setf path/experiments "~/trash/experimental")

(setq org-babel-default-header-args:shell '((:dir . path/experiments)))
(setq org-babel-default-header-args:dash '((:dir . path/experiments)))
(setq org-babel-default-header-args:zsh '((:dir . path/experiments)))

This is where the problem comes.
The problem
When evaluating code blocks whose language is shell, dash or zsh, I get the following error
Wrong type argument: stringp, path/experiments

The question
How can I use the value of a variable so that it affects all code blocks whose language is zsh, dash or shell?


texts: How to use bmkp-new-bookmark-default-names in bookmark+?

texts:
I am using bookmark+.el in Emacs 25.1. When I press C-x r m (bound to bookmark-set) and point is on a symbol, it will be used as the default candidate for the new bookmark to be created.

I would like to change this behavior slightly, such the the current line number (as given by line-number-at-pos) is appended to the name. So for example if point is on a symbol my-test-function at line 31 in a buffer my-lisp-functions.el and I press C-x r m the default candidate should be my-test-function:31 (and not just my-test-function as is the current behavior).

After browsing the file bookmark+-1.el, I think I have to customize the variable bmkp-new-bookmark-default-names. I would like to do this from lisp code (i.e. not use the M-x customize gui).

The documentation of the variable bmkp-new-bookmark-default-names says:

  The option value is a list of functions that do not require an
  argument and return a string (or nil).  They are invoked, in order, to
  produce the default names.


texts: how to fold xml file (or specifically build.xml)

texts: I am using spacemacs nXML mode to edit build.xml (java ant configuration file), the file is very long, how to fold and unfold it?


texts: helm-grep-do-git-grep : show only exact matching

texts:
Windows 10, Emacs 25, Helm
I want to find exact text "data autoupdate" in all files in some folder in my Android Git project.

So I use command

M-x helm-grep-do-git-grep

And input text "data autoupdate"

Here result:

As you can see it find 4 candiates.
But I not need first candidate. I need exact matches.
So the candidates must be 3.

How I can do this?


texts:
Here's how some of the double-struck unicode letters display in my copy of Emacs for Windows:

Here's how they display in Notepad:

Version of Emacs:

What's a good way to get Emacs to display all of these correctly?


texts: realgud ipdb how to highlight line being debugged

texts:
I debug a python source file with

M-x realgud:ipdb
then call ipdb as  python3 -m pdb <sourcepath> <args>

I get 2 windows: ipdb ... shell    and  my source buffer.

How can I get the line being debugged to be highlighted?


texts: How do I change a globalized minor mode's key bindings?

texts:
I'm using drag-stuff, which defines a minor-mode (drag-stuff-mode), a corresponding keymap (drag-stuff-mode-map), and a globalized minor mode (drag-stuff-global-mode).

I want to make some changes to the default keybindings, and I'd like to use the globalized minor mode, but my changes to the keymap don't seem to affect the globalized minor mode.

For example, after turning on drag-stuff-global-mode, describing drag-stuff-mode-map shows:

(keymap
 (M-left . drag-stuff-left)
 (M-right . drag-stuff-right)
 (M-down . drag-stuff-down)
 (M-up . drag-stuff-up))

I want to undefine M-left, so I evaluate:

(define-key drag-stuff-mode-map [M-left] nil)

but drag-stuff-mode-map remains unchanged, and I can confirm that M-left is still bound to drag-stuff-left.

If I use the regular (local) minor mode, everything behaves as expected, it's only when using the globalized minor mode that I run into this.

What's going on, and how can I achieve what I'm trying to do?


texts: Is there any principal difference between "A-Z" and upper?

texts:
I just want to make sure I understood this correctly.

(rx (one-or-more (any upper lower)))

is equal to

(rx (one-or-more (any "A-Z" "a-z")))

Correct?


texts:
I am using emacs 24.4 in -nw terminal mode. I know ruby-mode is included but I cannot get the following snippet to indent correctly in a .rb file.

private
    def
    end

Instead I can only get

private
def
end


texts: Eshell - confusion about weird order of evaluation in Haskell on Windows

texts:
I have wasted several hours trying to fix simple Haskell program where I tried to ask the user to enter a string and then display it.
The program looks like that:

main = do
  putStrLn "Enter something "
  entered <- getLine
  putStrLn ("You have entered " ++ entered)

After hours of chasing my tail and reading lots of Monad tutorials I have discovered that my program works fine in cmd prompt. Can you imagine my frustration at this point?

This SO question gave me a clue to try it in cmd: https://stackoverflow.com/questions/8361508/execution-order-with-not-what-i-expected?rq=1

Is it possible to fix eshell? If not what is the best way to develop Haskell on Windows with Emacs?

Temporary solution

After a bit of experimenting I decided to start cmd.exe with a customised script that sets my environment for Haskell development. The following script starts my cmd:

set PATH=C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH%
set INCLUDE=c:/msys64/mingw64/include
set XDG_DATA_DIRS=c:/msys64/mingw64/share
set PKG_CONFIG_PATH=c:/msys64/mingw64/lib/pkgconfig
set HASKELL_GI_GIR_SEARCH_PATH=c:/msys64/mingw64/share/gir-1.0

cd C:/Windows/System32/

cmd.exe

Using cmd sets my path correctly. I have tried a similar script that launches powershell, which gives me better autocompletion than cmd, but for some reason I can't make the PATH in powershell accept my script settings, other environment variables seem to be OK.

Another option

Following one commenter's question this is the version that works with eshell on Windows 10

import System.IO (hFlush, stdout)

main = do
  putStrLn "Enter a string"
  hFlush stdout
  ln <- getLine
  putStrLn ("Yo have entered " ++ ln)

Note the use of hFlush stdout after first printing that was causing problems.


texts: Enable spell check with american dictionary for all buffers

texts:
I have an init file that loads two files: one from customization done from within emacs and other from my custom settings file - better-defaults.el.

I have tried various options like ispell-local-dictionary "en_US", ispell-dictionary "american" and a few other flycheck declarations with setq-default inside better-defaults.el, but spell check is not working.

How do I enable spellcheck with American dictionary on the fly?

I'm using Emacs 26 on Windows 10.


texts:
Q:  How to remove / delete nth element of a list.

CAVEAT:  Do not remove all occurrences / members matching nth element -- e.g., eq or equal.

EXAMPLE:  Remove the 17th element of:

'(a b c d e f g h i j k l m n o p q r s t u v w x y z)

nth ELEMENT -- CHEAT SHEET / LEGEND:

element 0:   a
element 1:   b
element 2:   c
element 3:   d
element 4:   e
element 5:   f
element 6:   g
element 7:   h
element 8:   i
element 9:   j
element 10:  k
element 11:  l
element 12:  m
element 13:  n
element 14:  o
element 15:  p
element 16:  q
element 17:  r
element 18:  s
element 19:  t
element 20:  u
element 21:  v
element 22:  w
element 23:  x
element 24:  y
element 25:  z


texts:
I've got helm installed to work with comint mode either in eshell or when running python in an inferior comint process. I'd like to preserve the command line history, especially in the python mode.

Tried

(setq savehist-additional-variables '(comint-input-ring))

but that seems to result in the savehist file always containing

(setq comint-input-ring 'nil)

Other fields like search-ring, kill-ring, minibuffer-history save fine. Is there a way to do this?

I know this link answers it for a 'real' shell but it doesn't work in this case.

EDIT
As requested, what I've tried is the following, and it describes my use-case

(helm-mode 1)
(define-key comint-mode-map (kbd "C-S-l" 'helm-comint-input-ring)

elsewhere in .emacs

(require 'python-mode) ;; Goes to ipython.exe (on windows)

Coding some python, using C-c C-c to send to ipython process.

>>> somefunc()

This now appears if I use C-S-l as a helm-comint-input-ring and I can search on it.

I'd like to preserve these commands as I tend to repeat them across sessions (but with enough variability to not script it away completely).

I agree there could be both eshell, python , other comint buffers running, I suppose you are saying that ipython should preserve the history buffer and I should somehow get savehist to load that? Not sure how.


texts: How to run current buffer as python module from project root in Elpy mode?

texts:
Take for example I have the following project tree.

repo
|
+-root
  |
  +-__init__.py
  +-__main__.py
  +-packageA
    |
    +-__init__.py
    +-__main__.py

My buffer is currently at root.packageA.__main__. Due to relative imports within the code, it is necessary to run python -m root.packageA from repo.
How do I do so using elpy commands?


texts:
Often, I my windows get automatically split until I arbitrarily decide that the current frame does not have enough real-estate for them all. When this occurs, I manually delete a window, create a frame, and switch to that deleted window. How can I write an elisp function that does this?

I tried:

(defun pop-window-into-frame ()
  (interactive)
  (delete-window)
  (make-frame-command)
  (switch-to-prev-buffer))

But for some reason this doesn't do what I think it should.


texts: Magit: Files missing in status buffer when "Ignore all whitespace" is enabled

texts: In Magit I sometimes toggle Ignore all whitespace in the status buffer. This causes files that contain only whitespace changes to disappear. This means I cannot operate on them without toggling Ignore all whitespace and refreshing. Is there any option to change this behaviour?


texts: External command doesn't run in GUI mode

texts:
I have the following function attached to f2 key in latex mode:

(defun latex-compile ()
      "Runs pdflatex on current file"
      (interactive)
      (let* ((file-name (shell-quote-argument (buffer-file-name)))
            (process (start-process-shell-command
                           "pdflatex"
                           "*async pdflatex*"
                           (concat "pdflatex " file-name))))
            (set-process-sentinel process 'latex-sentinel)
            (setq new-window (split-window-below 30))
            (set-window-buffer new-window "*async pdflatex*")
            (other-window 1)
            (set-process-query-on-exit-flag process nil)
            (local-set-key (kbd "z") 'latex-kill-async-pdflatex)
            ))

pdflatex program is located in /usr/local/texlive/2016/bin/i386-linux. I have the following in .bash_profile and .bashrc:

PATH=$PATH:/usr/local/texlive/2016/bin/i386-linux

When I click <f2> in GUI Emacs, it says: "/usr/bin/bash: pdflatex: command not found".

But in console Emacs it works.

I have also added

(setq exec-path (append exec-path '("/usr/local/texlive/2016/bin/i386-linux")))

to .emacs, but it didn't help.


texts: Appropriate way to deal with file-names and file-name components ("paths") in emacs lisp?

texts:
What is a good, clean  to deal with paths in emacs lisp?
Common lisp has pathnames, Python has os.path. But I always seem to end up reinventing the wheel and resorting to manual regexes for simple path operations like getting a path basename, dirname, or joining paths together in a sane way.


texts:
Q: how do I suppress mu4e warnings about the update process?

I am using mu4e with mbsync.  Recently, the latter has started
to emit an error/warning message about losing track of messages.
When it does so, mu4e spits out a warning message:

[mu4e] Update process returned with non-zero exit code

That's normally fine, but it is annoying, especially as it spams
my echo area every time mu4e checks my email.

Until I figure out what the problem is with mbsync, I have to
tolerate the "losing track of messages" warning it gives.
However, I'd like to know how to tell mu4e to shut up about it
so it doesn't continue to alert me about non-zero exit codes.  How
do I do that?


texts: Automatically Highlighted Pdf Code Export [Org-Mode]

texts:
I want my Org Mode Latex Pdf Export to look like Code Styles and Colours

Colour definitions for the xcolor package have been added to

org-format-latex-header

It looks like that now:

 (setq org-format-latex-header
       '("\\documentclass{article}
 \\usepackage[usenames]{color}
 [PACKAGES]
 [DEFAULT-PACKAGES]
 \\definecolor{codegreen}{rgb}{0,0.6,0}
 \\definecolor{codegray}{rgb}{0.5,0.5,0.5}
 \\definecolor{codepurple}{rgb}{0.58,0,0.82}
 \\definecolor{backcolour}{rgb}{0.95,0.95,0.92}

 \\pagestyle{empty}             % do not remove
 % The settings below are copied from fullpage.sty
 \\setlength{\\textwidth}{\\paperwidth}
 \\addtolength{\\textwidth}{-3cm}
 \\setlength{\\oddsidemargin}{1.5cm}
 \\addtolength{\\oddsidemargin}{-2.54cm}
 \\setlength{\\evensidemargin}{\\oddsidemargin}
 \\setlength{\\textheight}{\\paperheight}
 \\addtolength{\\textheight}{-\\headheight}
 \\addtolength{\\textheight}{-\\headsep}
 \\addtolength{\\textheight}{-\\footskip}
 \\addtolength{\\textheight}{-3cm}
 \\setlength{\\topmargin}{1.5cm}
 \\addtolength{\\topmargin}{-2.54cm}"
         )
       )

mystyle settings

\lstdefinestyle{mystyle}{...}

have been added to

org-latex-listings-options

It looks like that now:

     (setq org-latex-listings-options
       '(("backgroundcolor" "\\color{backcolour}")
         ("commentstyle" "\\color{codegreen}")
         ("keywordstyle" "\\color{magenta}")
         ("numberstyle" "\\tiny\\color{codegray}")
         ("stringstyle" "\\color{codepurple}")
         ("basicstyle" "\\ttfamily\\footnotesize")
         ("breakatwhitespace" "false")
         ("breaklines" "true")
         ("captionpos" "b")
         ("keepspaces" "true")
         ("numbers" "left")
         ("numbersep" "5pt")
         ("showspaces" "false")
         ("showstringspaces" "false")
         ("showtabs" "false")
         ("tabsize" "2")
         )
       )

If I now use the export dispatcher with C-c C-e l L, and analyze the buffer nothing has changed.

1. Am I adjusting the settings/variables incorrectly?

2. Is there a better org mode way to get an automatically generated .pdf with code style highlighting?

  Edit 1:

  the org-latex-listings-options is inserted above every

\begin{lstlisting}
...
\end{lstlisting}

  and not once above the \begin{document}

  3. How can I optimize that

  Edit 2: Here some example Files (Naming should clarify the purpose)
  Don´t know how to attach files in StackExchange

  File Link


texts: Is there a 'caps-lock-mode' for those of us who've rebound the key?

texts:
Rebinding your caps-lock key to control is a popular thing to do (though there are arguments against it, even if a bit pedantic).  However, the language I find a lot of my time in uses runs of capitals pretty extensively.

Is there a caps-lock-mode that can simulate the behavior?  (Without affecting existing keybindings of course, e.g. striking C-x C-s will not send C-X C-S.)


texts:
I would like to use the helm machinery to search "live" a buffer's lines.
Is this possible? If not how would I go about figuring out how to implement this?


texts:
I have downloaded the yasnippet package which works very nicely for my Latex files. However, I often use Org mode to write my Latex documents.

The latex snippets from yasnipet dont seem to be "active" in org-mode. i.e. typing begin and pressing tab does not expand into \begin{..} \end{..}

How can I make the Latex yasnippets active in Org mode?


texts:
I just installed emacs 25 on Ubuntu (via apt install) and when I try to install jedi (after running package-refresh-contents) via package-install I'm getting the error message

  package-compute-transaction: Package ‘emacs-26.1’ is unavailable

I just did this on another machine a week ago and jedi installed fine on my emacs 25, so I'm confused.

Should I be able to install jedi on my emacs 25? If so, how can I do that given the error message that arises when I try?


texts:
I've taken to using org-mode for keeping track of my open tasks each week, notes on various tasks, and to generate a LaTeX formatted report at the end of each week that breaks down my time by task and subtask per day. This has all been great. I'm curious, however, if there's not some way to export this timesheet data for analysis in some other system or import into a holistic database. I like to use historical task data for estimates and the current structure makes it hard to aggregate my data and analyze it.

I was wondering if there was some way to export my logbook entries into something like a CSV file so I can import it into Excel or write a Python script to analyze it or something. If it might make this export easier, I'm considering moving from a 1 file per week organizational structure to one long running file per project. This should at least keep related log entries in physical proximity and more likely to be logged under the same entries.

Any ideas?


texts: Why isn't emacs-lisp-mode derived from lisp-mode?

texts:
Just out of curiosity, why isn't emacs-lisp-mode derived from lisp-mode? Instead, both are derived from prog-mode.

It seems to me that there is a natural hierarchical relationship that should exist. Is the current situation simply a case of historical accident, or is there a good reason that emacs-lisp-mode should not derived from lisp-mode?


texts: Prevent org-mode from unfolding pasted outlines

texts:
When I copy an outline into an org-mode buffer, Emacs automatically unfolds it.  How can I prevent it from doing so?

I always want the outlines I paste in to be fully folded.

Here's an example:

If my org-mode buffer looks like:

* A
** AA
*** AAA
** AB
*** ABA
* B
** BA
*** BAA
** BB
*** BBA
* C
** CA
*** CAA
** CB
*** CBA

and I fold all those outlines up, so that org shows them as:

* A...
* B...
* C...

Then I cut (or kill) the * A... outline, so I'm just left with:

* B...
* C...

Normally, by default, when I paste (or yank) the previously cut (killed) * A... outline, org inserts it and unfolds it so that it looks like:

* B...
* A
** AA
*** AAA
** AB
*** ABA
* C...

Instead, when I paste it in, I'd like it to be fully folded, so that it looks like:

* B...
* A...
* C...


texts:
My default line wrapping is 'truncate long lines'.
How can I change it to 'wrap line at window edge' ?


texts: Choosing which font for html export syntax highlighting?

texts:
Exporting org mode documents to html with (setq org-src-fontify-natively t) will carry syntax highlighting into the exported code blocks.

Zenburn looks awful exported while Leuven/others looks fantastic. I do all my work in Zenburn.

Can html-export use a specified font for source code highlighting? Running (in spacemacs) the command Space T n changes the font, but it is not practical to keep going back and forth whenever I wish to html-export.

The following article http://emacs-fu.blogspot.com/2010/05/using-zenburn-for-org-mode-generated.html I found during my search but the provided solution is neither the same nor works.


texts: Calling functions in .dir-locals in Emacs

texts:
I'm trying to activate flycheck-mode by default when opening any file in my project's directory. I'm a bit of an elisp newbie, my .dir-locals.el file looks like this:

((nil . (mode . flycheck-mode))
 ((cmake-ide-dir . "~/workspace/Samira3D"))
 ((cmake-ide-build-dir . "~/workspace/Samira3D/build/")))

And the error I'm getting is

Invalid function: (nil mode . flycheck-mode)

How would I go about solving this?


texts: Slowness opening and moving around within large files

texts:
I'm running spacemacs 0.200.13 on emacs 25.3.1 from a macOS 10.12 machine.

In some scenarios, things feel very sluggish. They get worse as a dozen buffers or so are opened during the day. From the information below, how could I improve things?

I've started disabling linum-relative-mode and this has been helpful. Although having to disable line numbering is quite impractical from a text editor...

Opening and navigating in a file that contains about a thousand lines, here is the result of a profiler run:

- command-execute                                         136,548,463  75%
 - call-interactively                                     136,548,463  75%
  - funcall-interactively                                 106,982,148  59%
   - spacemacs/helm-find-files                             62,811,296  34%
    - let*                                                 62,811,296  34%
     + helm-find-files-1                                   62,806,176  34%
     + cond                                                     5,120   0%
   + helm-M-x                                              21,400,635  11%
   + evil-goto-line                                        12,380,900   6%
   + org-cycle                                              8,550,289   4%
   + evil-next-line                                         1,012,448   0%
   + evil-previous-line                                       826,580   0%
  + byte-code                                              29,566,315  16%
+ linum-update-current                                     35,843,195  19%
+ redisplay_internal (C function)                           6,892,632   3%
+ timer-event-handler                                         817,048   0%
+ winner-save-old-configurations                               32,416   0%

Editing a JSX file that's only 200 lines, here is the profiler:

- command-execute                                          67,036,616  71%
 - call-interactively                                      67,034,504  71%
  - funcall-interactively                                  35,498,016  38%
   - helm-M-x                                              25,212,868  26%
    - command-execute                                      25,212,868  26%
     - call-interactively                                  25,212,868  26%
      - byte-code                                          15,288,051  16%
       - completing-read                                   15,288,051  16%
        + #<compiled 0x46658893>                           15,288,051  16%
      + funcall-interactively                               9,924,785  10%
   + spacemacs/kill-this-buffer                             4,504,190   4%
   + evil-previous-line                                     2,680,056   2%
   + evil-ex                                                  729,371   0%
   + evil-next-line                                           695,756   0%
   + evil-delete                                              511,784   0%
   + evil-paste-after                                         384,176   0%
   + evil-search-next                                         235,082   0%
   + evil-window-down                                         154,040   0%
   + profiler-report-toggle-entry                              76,249   0%
   + evil-visual-line                                          67,808   0%
   + evil-end-of-line                                          52,896   0%
   + evil-goto-first-line                                       7,520   0%
  + byte-code                                              30,176,090  32%
  + list                                                    1,359,342   1%
+ linum-update-current                                     14,198,340  15%
+ redisplay_internal (C function)                           6,652,776   7%
+ timer-event-handler                                       3,692,719   3%


texts: How do I set up my .emacs.d folder on Windows?

texts:
I am using the latest version of Emacs on Windows 7.

I unzipped Emacs to: C:\Users\MyName\OneDrive\emacs

.emacs.d is in: C:\Users\MyName\AppData\Roaming

I would like to have to set up .emacs.d in C:\Users\MyName along with an init.el instead of ~.emacs. Do I transfer .emacs.d to the new location or create a new .emacs.d folder?

I assume changing the .emacs.d location will also require me to change %HOME%. If so, how do I change the home variable?


texts: Paste Windows clipboard with Shift-Insert but not by yanking

texts:
I am using Emacs 24.4 on Windows 10. I only ever use it in -nw (no-window) mode.

I would like Emacs to paste from the Windows clipboard only on Shift-Insert and not on yank (Ctrl-y). I have tried this:

(setq x-select-enable-clipboard nil)
(setq x-select-enable-primary nil)

but this disables pasting from the Windows clipboard on both Shift-Insert and yank. I want Shift-Insert to paste only from the Window clipboard and yank to paste only from the Emacs kill ring.

Here is an example of what I want:

Copy the text hello to the Windows clipboard.
Start emacs.
Do a yank (Ctrl-y); desired result: nothing is inserted.
Do a Shift-Insert; desired result: hello is inserted.

Is this possible? If so, how?


texts: version control using the usual backup system of Emacs

texts:
This question is inspired by https://emacs.stackexchange.com/a/7831/ and the below settings borrowed from that answer :

(setq backup-directory-alist '(("." . "~/emacs-backups"))
      version-control 'numbered
      make-backup-files t
      delete-old-versions 'never)

I am wondering if it would be possible that emacs keeps an unlimited backups of a list of files defined by the user and for other files to behave like its usual backup system.

The motivation is that it would be desirable that Emacs keeps several backups of a list of some important files (defined by the user), like ~/.emacs /path/to/my_important_file.txt, (1) by creating a numbered version control of them, like the above code (2) never deletes the old versions and (3) for other files, Emacs keeps its standard backup system.

Added:
Based on the answer provided by Drew (suggesting to use local variables and the version-control variable) we can add this at the end of the files that we would like to keep an unlimited number of backups of them (for making the changes permanent, after reopening the file we can answer the question about applying the values of the these variables by !):

;; Local Variables:
;; version-control: t
;; make-backup-files: t
;; delete-old-versions: never
;; End:

For keeping the last N backups of a file we should add this at the end of that file
(for example for N=50):

;; Local Variables:
;; version-control: t
;; make-backup-files: t
;; delete-old-versions: t
;; kept-new-versions: 50
;; kept-old-versions: 0
;; End:


texts: How configure keybinding for Yasnippet only?

texts:
When you insert a snippet from Yasnippet, you have this, for example

# --------------------------------------------------------------
# $1 (`(insert-date)`)
# --------------------------------------------------------------
$2

Then you press tab, to switch from the place $1 to the place $2.

If you are not in a snippet, the tab key works normal.

I figured out the function that's get called when you press Tab into snippet, is yas-next-field. I would like to bind the function to another key instead Tab.

But only when it's inside a snippet, not affecting the normal working of another key outside snippet, like Tab already is.

But I couldn't find any refefence on internet about keymapping for only inside yasnippet, not as normal key.

Thanks in advance for the suggestion, it's really appreciated.


texts: How to jump up or down to first non-whitespace character in same column

texts:
I use evil-mode with Emacs and would like to accomplish this via evil-mode, but would be fine with doing it in an Emacs centric way too. The subject line explains it well, but here is a post in which a Vim user posited the same question as mine and received the Vim-centric answer (several actually): How do I move vertically until reaching a non-whitespace character?

Another useful link, similar to that provided above: Move to the next row which has non-white space character in the same column in VIM?

Thanks in advance.

UPDATE: I decided I'd write a function to do this and it was surprisingly easy:

(defun jump-down-to-non-whitespace-char-in-same-column ()
  (interactive)
  (next-line)
  (while (or (= (char-after (point)) 32)
             (= (char-after (point)) 10))
    (next-line)))

I guess I'd still like to know if there is a way to do it with evil-mode anyway just because I am curious, so I won't answer my own question yet.

UPDATE 2: I prefer the following version instead as now I use evil-next-line and evil-previous-line which behave more consistently the way I want:

(defun jump-down-to-non-whitespace-char-in-same-column ()
  (interactive)
  (evil-next-line)
  (while (or (= (char-after (point)) 32)
            (= (char-after (point)) 10))
    (evil-next-line)))

(defun jump-up-to-non-whitespace-char-in-same-column ()
  (interactive)
  (evil-previous-line)
  (while (or (= (char-after (point)) 32)
            (= (char-after (point)) 10))
    (evil-previous-line)))

Then in my evil-leader config I use "c d" 'jump-down-to-non-whitespace-char-in-same-column and "c u" 'jump-up-to-non-whitespace-char-in-same-column


texts: What key sequence is killing a large chunk of my buffer?

texts:
What is the key sequence for deleting from the current position to
the beginning of the buffer?

I ask not because I want to use the sequence but to prevent it from happening.   I always do this by mistake, often when I'm working too fast, and I don't realize it until later.  It happens only maybe four times per year, but sometimes, if I don't realize it soon enough, it can be devastating.

I could disable the function or sequence if I only knew what it was.

Maybe I'll have to turn on some sort of keystroke log to find out exactly how I make this mistake?

I've noticed that the problem occurs when I'm in text-mode.  I'm using EMACS 24.3.1 on Windows 10, in case that's relevant.


texts: Is it possible to clear src results in org-mode?

texts:
I have a simple org-mode document:

#+TITLE: My Document

#+BEGIN_SRC python :results raw :hlines yes
  return 'hello world!'
#+END_SRC

Issuing C-c C-v C-b and responding yes to the prompt to evaluate the python code block yields

#+TITLE: My Document

#+BEGIN_SRC python :results raw :hlines yes
  return 'hello world!'
#+END_SRC

#+RESULTS:
hello world!

Repeating this command yields

#+TITLE: My Document

#+BEGIN_SRC python :results raw :hlines yes
  return 'hello world!'
#+END_SRC

#+RESULTS:
hello world!
hello world!

My problem is that I don't want the old results kept once I reevaluate my src block. Is there a command to clear the old results?


texts: How do I highlight certain words between double quotes with font-lock?

texts:
I'm trying to add additional colors to json-mode for when I edit json-schema.  I can get it working fine without searching for double quotes, but I need to for some highlighting.  I've tried quite a few things to highlight properties inside of "properties" including:

(font-lock-add-keywords 'json-mode '(("""\\(properties\\)""" 1 '(:foreground "chartreuse4") t))
(font-lock-add-keywords 'json-mode '(("\\""\\(properties\\)"\\"" 1 '(:foreground "chartreuse4") t))
(font-lock-add-keywords 'json-mode '(("\\s""\\(properties\\)\\s""" 1 '(:foreground "chartreuse4") t))

I expect once I understand the solution, I can easily highlight object in "type": "object" which was my original goal.


texts: How can I convert an inline pseudo YAML dictionary to a valid multiline one?

texts:
Consider this code:
- name: Cron set up
  cron: name=something something="anything" job="/bin/bash -c 'service=nslcd; [[ -x /usr/bin/$service ]] && systemctl restart $service'" minute={{ some_cron_minute }}
  state: present

How can I change it into this:
- name: File created
  cron:
    name: something
    something: "anything"
    job: "/bin/bash -c 'service=nslcd; [[ -x /usr/bin/$service ]] && systemctl restart $service'"
    minute: "{{ some_cron_minute }}"
  state: present

It's totally ok, maybe even preferred, if the code would work only for a single line instead of the whole buffer. I mean that I'll put the cursor on the cron:  line and use the created function to transform the line to the final YAML dict.
What needs to be done:

new line after :
every dictionary key has to be placed on its own line, indented by two more space then parent key (cron: in this case)
key and value is separated by =
there may be = in value too, like in job example above. But in such case there are always quotes around value.
value may be in quotes
optional: if value has {{ text inside, put double quotes around

What I tried
I used to deal with this using a semi-working regular expression, but I recently lost it from history. When faced with challenge to write it again, I thought it might be much better to use some parser-like approach to this.
Most importantly - this is not only a similar case I'm dealing with and I would like to learn a better approach then regular expressions.
Background for this specific task
Some time ago it was possible to pass arguments to modules in Ansible on a single line instead of using a valid YAML dictionary. I went with that possibility because it was easier to search for patterns with *Occur* then with multi-line dictionaries.
Anyway these days this syntax is not recommended. And I have hundreds of files with the wrong syntax. I don't want to replace all occurrences everywhere. It is more convenient (and safe) for me to convert only single tasks when I'm changing something in them so I can test immediately.


texts: isearch buffer greyed out/blurred after update to macOS 11.3

texts:
I'm running Mac Port version of emacs 27.2 on macOS big sur. I recently updated to macos 11.3, and I'm having some strange behavior when I do a C-s search. In around 75% of instances, the entire buffer turns blurred-out/grey except for the search matches (see screenshot). It looks like the semi-transparent background macOS puts behind many objects (e.g., dock, spotlight search)
Even after I've exited isearch, the greyed background persists until I switch buffers and switch back, so it's quite annoying. I experience the issue on both integrated MacBook screen and external displays.
Things I've tried:

Reducing transparency in macOS preferences
Disabling spotlight search in macOS preferences
updating from emacs 27.1 --> 27.2
stripping down .emacs file

How can I fix this?


texts: Working Around the OS X Catalina Conflict with Emacs 26.3

texts:
I'm struggling to workaround the problem discussed in this post. I'm working through the accepted solution (which also references this post, and getting what I think is close, but not quite there. The steps I'm taking—-just to try to recap my integration of multiple SO posts--are:

Putting the following script into a file called emacs_catalina_wrapper, which now resides in my Laptop-level Applications folder (i.e. not my user-level Applications folder). That script (shell set to /bin/bash, which is what I'm using in Terminal) is exactly:

if ! pgrep Emacs; then
    open -a Emacs.app
    sleep 1
fi
for f in "$@"
do
    /usr/local/bin/emacsclient -cn -d localhost:0 "$f"
done

(I added -d localhost:0 because I was otherwise getting the error discussed here.)

I then run the following from terminal:

MyMac:bin$open -a /Applications/emacs_catalina_wrapper.app my_python_script.py

Whether or not Emacs is already running, that brings up a blank window (which appears to bear the name of that script, but contains none of its text -- my_python_script.py is not new...it's an existing script I'm looking to edit, not create). my_python_script.py lives in the directory I'm running this from, btw.

What am I missing? I'm not even sure what additional information to add here to help you help me!


texts: Alarmbell on saving .py file if linting errors using flake8

texts:
I'd like to configure Emacs to play an audible noise when saving my .py files but only if there is a linting error present.

I currently have flycheck linting done on the fly and autopep8 settings applied on saving with the following configuration...

;; Use flycheck rather than flymake with elpy
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))
(add-hook 'python-mode-hook
          (lambda ()
            (setq flycheck-python-pylint-executable "~/.virtualenvs/dskit/bin/pylint")
            (setq flycheck-pylintrc "~/.emacs.d/settings/.pylintrc")))

;; enable autopep8 formatting on save
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)

...and was thinking that a hook added to 'py-autopep8-enable-on-save might be the way forward, but am still on the starting slopes of the Lisp learning curve and would appreciate any pointers or suggestions.


texts:
I'm trying to abstract elisp code for my dynamic folders on mu4e but for some reason executing a command fails with mu4e-error: [mu4e] mu4e-xxxx-folder evaluates to nil, here is the current code:

  (setf shackra/mu4e-maildir-dirs '("yahoo" "kue" "gmail"))
  (defun shackra/mu4e-find-maildir (msg place &optional alternative)
    (if msg
        (let ((msg-maildir (mu4e-message-field msg :maildir)))
          (dolist (maildir shackra/mu4e-maildir-dirs)
            (when (string-match-p (concat "^/" maildir) msg-maildir)
              (concat "/" maildir "/" place))))
      (if alternative
          alternative
        (dolist (maildir shackra/mu4e-maildir-dirs)
          (when (string-match-p maildir user-mail-address)
            (concat "/" maildir "/" place))))))
  (setf mu4e-sent-folder ;; carpeta de enviados
        (lambda (msg)
          (shackra/mu4e-find-maildir msg "Sent")))
  (setf mu4e-drafts-folder ;; carpeta de borradores
        (lambda (msg)
          (shackra/mu4e-find-maildir msg "Drafts")))
  (setf mu4e-trash-folder ;; carpeta de correo borrado
        (lambda (msg)
          (shackra/mu4e-find-maildir msg "Trash" "/gmail/Trash")))
  (setf mu4e-refile-folder ;; carpeta de correo salvado
        (lambda (msg)
          (shackra/mu4e-find-maildir msg "Archive" "/gmail/Archive")))


texts: Weird behavior when inserting parentheses in keyboard macro

texts:
In my init file, I have these bindings:

(global-set-key (kbd "C-x S-SPC") (kbd ")"))
(global-set-key (kbd "S-SPC") (kbd "("))

Now, starting with empty buffer, if I define this keyboard macro:

S-SPC f o o C-x S-SPC RET

edit-kbd-macro shows:

Command: last-kbd-macro
Key: none

Macro:

S-SPC
(foo            ;; self-insert-command * 4
C-x S-SPC
)           ;; self-insert-command
RET         ;; newline

Then when I repeat my macro, I end up with the following buffer contents:

(foo)
((foo))

Obviously I want the second line to be exactly like the first one, how can I fix it?


texts: How to right align some items in the modeline?

texts:
Given the following modeline configuration:

(setq-default mode-line-format
   (list
    ;; Current buffer name
    "%b "
    ;; Major mode
    "[%m] "
    ;; Modified status
    "[%*] "
    ;; Cursor position
    "Line: %l/%i Column: %c"))

I would like for the last item to appear right-aligned.


texts: How to view scheduled tasks or deadlines that are late

texts:
In agenda view, how can I make a list of all tasks (more than 30 ongoing tasks) that are late?

That should included recurring scheduled tasks for the month, were I jumped a day. For example, had to do something 1,2,3,4, but did it 1,2,4. The list should keep track that some item was skipped.


texts: Warning in WDired when renaming files to change capitalisation

texts:
I often use the command C-x C-q in dired (bound to dired-toggle-read-only) to rename files.

When I use this to change only capitalisation (eg, Foo.bar to foo.bar) then I use C-c C-c to apply the changes (wdired-finish-edit), I get a warning saying

  File /../../foo.bar already exists; rename to it anyway? (y or n)

I get that I couldn't create two files with the same name if the difference is just the capitalisation, but I believe this warning is not necessary if I am just renaming a file. I think WDired could be made aware of the fact that it is just renaming a file and not creating a new one with the same name. Is there a way to fix this so I don't get the warning if I am just renaming a file with dired-toggle-read-only?

(I am aware that I can use R on dired to rename a file, but I often change names in bulk, even using the rectangular selection to remove blocks of characters from many file names at once).


texts: How can I auto-insert semi-colon and colon after property autocompletion in css-mode?

texts:
Inside a CSS declaration, you got the property, the part before the colon, that can mostly always be auto-completed:

strong {
  color: red;  /* <= color is the property */
}

After hitting return from the menu of your completion tool (let's say Company), it is very likely you will type:, the value of your property and then ;.

What I think of is that, after hitting return, the colon and semicolon should be auto-inserted and then the point should be positioned right before the semicolon:

/* Point position before completion */
strong {
  /*  v */
  colo
}

/* Point position after completion */
strong {
  /*     v */
  color: ;
}

Any hints about this?

Note: I saw this behavior in Atom CSS plugin.


texts:
I can't use use-package with Emacs master. How can I find out why this is?
For me, all calls (via eval-last-sexp) to use-package fail as
Error (use-package): Cannot load X Disable showing Disable logging

where X is the package of interest.
How do I get details about the error? use-package suppresses the stack trace. Running Emacs with --debug-init gives the same results.